akexorcist / Localization

[Android] In-app language changing library
Apache License 2.0
983 stars 154 forks source link

java.lang.RuntimeException: Using WebView from more than one process at once #129

Open ryandt opened 2 years ago

ryandt commented 2 years ago

Hey there. My app's bug reporting tool is reporting several crashes around the use of WebView in LocalizationApplicationDelegate.

Unable to create application [application.name]: 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 [process name] (pid 20098), lock owner [process name] (pid 21177)

I'm unfortunately not sure how to reproduce this crash. My best guess is that my application is trying to instantiate a WebView on startup with the same process name as another instance of my app that is in the process of getting killed.

oschildt commented 2 years ago

I see that the WebView is used in LocalizationApplicationDelegate like this

class LocalizationApplicationDelegate {
    fun onCreate(context: Context) {
        WebView(context).destroy()
    }
    ...
}

An WebView object is created and immediately destroyed created and immediately destroyed. I am sure this is the reason of your problem.

For what a WebView is required to handle localization issues?

ryandt commented 2 years ago

@oschildt That's right. This was most likely added to address this issue. But unfortunately this workaround introduces an issue of its own with multiple processes being active at once.

akexorcist commented 2 years ago

Since AndroidX AppCompat has per-app language preferences for backward compatibility. Please migrate this library to AndroidX for more stability, compatibility, and longer support from Google team.

See Migrate to AndroidX guide

Thank you for your support