Multiple processes of an App exist at the same time.
Recently, my app's had a lot of crashes only on Android 9, 10, here is a crash log from Firebase Crashlytics:
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 org.xlotus.ktesteverything (pid 7032), lock owner org.xlotus.ktesteverything (pid 9186)
My app does not use multiple process for any Android Components or others, and also you can see that there are two process(current process and lock owner process) having the same name (my app's package name), why does it happen?
You may think the crash relating to WebView and I should contact to Chromium team, but the root cause is the old process of my App didn't exit and still held the lock of WebView data directory, when user opens the app again, it will run on another process and also want to hold the lock, in this situation, WebView is forced to throw the Exception to avoid race condition (Ref).
Furthermore, Some users got the crash multiple times for about 1 hour with the crash log showing the same lock owner, which means the old process of my app didn't exit and still held the exclusive lock of WebView data directory for a long time. As a result, every time users opened my app again, and when they used a feature using WebView, the crash occurred.