Enable WebViewFasterGetDefaultUserAgent by default#1140
Draft
inthewaves wants to merge 1 commit into
Draft
Conversation
Apps, in particular ones that use Google Mobile Ads SDK, can dead lock. A worker thread in the Mobile Ads SDK holds a singleton lock and calls WebSettings.getDefaultUserAgent() which block until a task posted to the main thread to initialize WebView finishes. Meanwhile, the main thread of the app enters Mobile Ads SDK. If the Dynamite ads module is not available, the library has a local fallback path which attempts to acquires the singleton lock that the worker thread is holding. The result is that the main thread gets blocked on a lock held by the worker thread which is waiting for main thread to process its task. Dynamite ads module can be unavailable if Play services + Play Store are not installed (or have some other issue). This would block users from using any app with SDK used in this way. By enabling this feature, the worker thread no longer waits on the initialization task posted to main thread to finish and gets a user agent immediately. This works around this deadlock. Note that Vanadium config doesn't handle WebViewCachedFlags which is meant to be fast and designed around SharedPreferences. The feature is only read in the relevant location from WebViewCachedFlags, so the native feature change is just for completeness. Test: Install app like com.faitaujapon.otg which had this issue. With no Play services install, app no longer ANRs on start Test: tools/autotest.py -C out/Default \ android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewThreadTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1139
Applies on #1138
Apps, in particular ones that use Google Mobile Ads SDK, can dead lock. A worker thread in the Mobile Ads SDK holds a singleton lock and calls WebSettings.getDefaultUserAgent() which block until a task posted to the main thread to initialize WebView finishes. Meanwhile, the main thread of the app enters Mobile Ads SDK. If the Dynamite ads module is not available, the library has a local fallback path which attempts to acquires the singleton lock that the worker thread is holding. The result is that the main thread gets blocked on a lock held by the worker thread which is waiting for main thread to process its task.
Dynamite ads module can be unavailable if Play services + Play Store are not installed (or have some other issue). This would block users from using any app with SDK used in this way.
By enabling this feature, the worker thread no longer waits on the initialization task posted to main thread to finish and gets a user agent immediately. This works around this deadlock.
Note that Vanadium config doesn't handle WebViewCachedFlags which is meant to be fast and designed around SharedPreferences. The feature is only read in the relevant location from WebViewCachedFlags, so the native feature change is just for completeness.
Test: Install app like com.faitaujapon.otg which had this issue. With no Play services install, app no longer ANRs on start
Test:
tools/autotest.py -C out/Default android_webview/tools/system_webview_shell/layout_tests/src/org/chromium/webview_shell/test/WebViewThreadTest.java