You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AwDataDirLock.java引发千次崩溃,求问题原因及解决方案

WebView跨进程数据目录冲突崩溃求助

我们的应用出现大量崩溃问题,涉及193名用户,累计崩溃次数达5700次。Firebase捕获到的崩溃日志如下:

Fatal Exception: java.lang.RuntimeException: Using WebView from more than one process at once with the same data directory is not supported. https://crbug.com/558377 : Current process com.myAppName (pid 16059), lock owner  unknown
   at org.chromium.android_webview.AwDataDirLock.b(AwDataDirLock.java:106)
   at org.chromium.android_webview.AwBrowserProcess.l(AwBrowserProcess.java:143)
   at com.android.webview.chromium.H.e(H.java:206)
   at vd4.run(vd4.java:337)
   at android.os.Handler.handleCallback(Handler.java:873)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:214)
   at android.app.ActivityThread.main(ActivityThread.java:6981)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)

(附Firebase崩溃统计截图:Firebase崩溃统计截图)

我已针对该问题排查许久并尝试多种方案,已知这类问题通常出现在使用AdMob的应用中,但我司应用未使用AdMob及依赖AdMob的第三方库。

当前WebView初始化代码在myApplication.kt的onCreate()方法中:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
    var processName = getProcessName(applicationContext)
    if (TextUtils.isEmpty(processName)) {
        processName = packageName + "_" + System.currentTimeMillis()
    }
    try {
        WebView.setDataDirectorySuffix(processName!!)
    } catch (exception: Exception) {
        //log
    }
}

private fun getProcessName(context: Context?): String? {
    if (context == null) return null
    try {
        val manager = context.getSystemService(ACTIVITY_SERVICE) as ActivityManager
        for (processInfo: ActivityManager.RunningAppProcessInfo in manager.runningAppProcesses) {
            if (processInfo.pid == Process.myPid()) {
                return processInfo.processName
            }
            //log
        }
    } catch (e: Exception) {
        //log
        return null
    }
    return null
}

(附涉事设备列表截图:涉事设备列表截图)

恳请技术同行帮忙分析该崩溃的原因,并提供可行的解决方案。

内容的提问来源于stack exchange,提问作者Yoni Moseri

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 00:30:41