Skip to content
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

ApplicationNotResponding: Background ANR #21679

Open
sentry-io bot opened this issue Feb 12, 2025 · 3 comments · May be fixed by #21681
Open

ApplicationNotResponding: Background ANR #21679

sentry-io bot opened this issue Feb 12, 2025 · 3 comments · May be fixed by #21681
Assignees
Labels
[Type] ANR Application Not Responding

Comments

@sentry-io
Copy link

sentry-io bot commented Feb 12, 2025

Sentry Issue: JETPACK-ANDROID-1307

ApplicationNotResponding: Background ANR
    at org.wordpress.android.fluxc.network.UserAgent.<init>(UserAgent.kt:17)
    at org.wordpress.android.modules.AppConfigModule.provideUserAgent(AppConfigModule.java:36)
    at org.wordpress.android.modules.AppConfigModule_ProvideUserAgentFactory.provideUserAgent(AppConfigModule_ProvideUserAgentFactory.java:51)
    at org.wordpress.android.DaggerWordPressRelease_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get0(DaggerWordPressRelease_HiltComponents_SingletonC.java:11957)
    at org.wordpress.android.DaggerWordPressRelease_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get(DaggerWordPressRelease_HiltComponents_SingletonC.java:13317)
...
(50 additional frame(s) were not displayed)
@dangermattic
Copy link
Collaborator

dangermattic commented Feb 12, 2025

Thanks for reporting! 👍

@nbradbury
Copy link
Contributor

nbradbury commented Feb 12, 2025

Note this crash occurs when calling android.webkit.WebSettings.getDefaultUserAgent(WebSettings.java:1402), which we do in UserAgent.init. This is a known issue and is by design.

If you need the user agent string but you don't need it immediately, then you can spawn a background thread early during your app startup which calls WebSettings.getDefaultUserAgent(). This will force WebView to load its code. Then you can just call WebSettings.getDefaultUserAgent() a second time whenever you need the user agent string...the second time you call this will be much faster. However you should be aware that calling WebSettings.getDefaultUserAgent() will still do some (not all) of its work on the UI thread, so you may want to initialize your app's UI before doing this.

@nbradbury nbradbury linked a pull request Feb 12, 2025 that will close this issue
@nbradbury nbradbury self-assigned this Feb 12, 2025
@nbradbury
Copy link
Contributor

See discussion on the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] ANR Application Not Responding
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants