This is the stacktrace we are seeing on 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 [Our package] (pid 28562), lock owner [Our package] (pid 13324)
org.chromium.android_webview.AwDataDirLock.b (AwDataDirLock.java:27)
as0.i (as0.java:30)
as0.b (as0.java:17)
as0.k (as0.java:2)
com.android.webview.chromium.WebViewChromiumFactoryProvider.g
(WebViewChromiumFactoryProvider.java:2)
com.android.webview.chromium.WebViewChromium.init (WebViewChromium.java:14)
android.webkit.WebView.<init> (WebView.java:435)
android.webkit.WebView.<init> (WebView.java:355)
android.webkit.WebView.<init> (WebView.java:337)
android.webkit.WebView.<init> (WebView.java:324)
android.webkit.WebView.<init> (WebView.java:314)
[Our code initializing the webview]
android.os.Handler.handleCallback (Handler.java:938)
android.os.Handler.dispatchMessage (Handler.java:99)
android.os.Looper.loop (Looper.java:246)
android.app.ActivityThread.main (ActivityThread.java:8506)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)
We have not been able to reproduce this, but we get hundreds/thousands of these crashes on Firebase. What is weird is that 99% of the crashes are happening on Samsung devices running Android 11. Our app is also a single process app, so it should not be running multiple processes. I’ve posted in the chromium issue tracker, but it seems the bug is more with the Samsung OS than with the webview itself, so I thought I’d post here as well.
It seems that some users have a process of our app running for hours, holding onto this Webview lock. However when they try to open our app, it is starting a new process instead of the existing process, and causing a crash.
I’m trying to gain more information: Does anyone have any insight into why this would be happening specifically on Samsung Android 11? Is there something our app, or our users, can do to mitigate this issue? Has anyone else faced this problem and found a workaround?