-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ANR getting default user agent #21681
base: trunk
Are you sure you want to change the base?
Conversation
Generated by 🚫 Danger |
|
App Name | ![]() |
|
Flavor | Jalapeno | |
Build Type | Debug | |
Version | pr21681-3ac50ab | |
Commit | 3ac50ab | |
Direct Download | jetpack-prototype-build-pr21681-3ac50ab.apk |
|
App Name | ![]() |
|
Flavor | Jalapeno | |
Build Type | Debug | |
Version | pr21681-3ac50ab | |
Commit | 3ac50ab | |
Direct Download | wordpress-prototype-build-pr21681-3ac50ab.apk |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #21681 +/- ##
==========================================
- Coverage 39.41% 39.30% -0.11%
==========================================
Files 2122 2116 -6
Lines 99570 99391 -179
Branches 15324 15316 -8
==========================================
- Hits 39247 39068 -179
Misses 56844 56844
Partials 3479 3479 ☔ View full report in Codecov by Sentry. |
@nbradbury just a FYI that we had a similar fix done in FluxC few months ago (wordpress-mobile/WordPress-FluxC-Android#3067), then we had to revert it (wordpress-mobile/WordPress-FluxC-Android#3101) as it led to some worse crashes. Please review the above before proceeding with the merge. |
@hichamboushaba Thanks for the background, that's very helpful! I'm going to revert this to a draft until I've had time to fully look into this. |
FYI: @nbradbury I started looking into that, but since you reverted it I'll now stop until until further notice. ⏱️ |
FYI: I just removed myself from this draft PR, just so to not have this on my review-requested GH view. Feel free to add me back to it when and if need-be. |
@hichamboushaba My understanding is that the issue with the FluxC fix was that moving |
We still use use |
|
Fixes #21679
Fixes #20147
We have a long-standing ANR caused by reading
WebSettings.getDefaultUserAgent
on the main thread. As noted in this comment on the Google issue:To work around this problem, this PR first sets the global user agent to the app name & version, then sets the global user agent by calling
getDefaultUserAgent
in a separate thread. Note that this occurs whenUserAgent.initialize
is called, which happens during app start.Because of this, there is a non-zero chance that a network call may be made with the app name & version as the user agent (ie: before the background thread to
getDefaultUserAgent
completes), but this is unlikely, and regardless it's better than having hundreds of users affected by the ANR.I'm unsure of what testing steps to recommend, other than setting a breakpoint here to ensure we're setting the user agent correctly. It may also help to add the line below above this line.
This will cause the app to delay 5000ms before retrieving the user agent, which will verify that it is actually being retrieved on a background thread instead of on the main thread because the app doesn't hang.