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

Removes multiple calls to the WebSettings.getDefaultUserAgent api #20603

Merged
merged 7 commits into from
Apr 11, 2024

Conversation

antonis
Copy link
Contributor

@antonis antonis commented Apr 5, 2024

Fixes #12259

Description

This PR replaces multiple calls to the WebSettings.getDefaultUserAgent(which is not recommended) with just one, hoping to prevent the ANR of #12259 and probably reduce the crash count in #20147

The current implementation is making 27 calls to the WebSettings.getDefaultUserAgent function during the app startup and more later. One of those was in the AppInitialiser and the rest were calls to the AppConfigModule that uses the FluxC implementation.

Since I wasn't able to reproduce the ANR my plan is to monitor how this fix would affect the occurrences of the issue. If the issue persist I would probably try a more drastic approach of changing the user agent used for the api calls and keep the full user agent using the WebSettings.getDefaultUserAgent only for the WebViews.

Internal ref: pcdRpT-5Us-p2#comment-9676


To Test:

  • Since this PR should not change the behaviour of the app but the refactored code affects all network calls a sanity check of the app is recommended.
  • Test Jetpack and WordPress, rest and xmlrpc
  • Verify that the AppInitializer.userAgentString is logged correctly

Regression Notes

  1. Potential unintended areas of impact

    • All Networking 😅
  2. What I did to test those areas of impact (or what existing automated tests I relied on)

    • Manual testing
  3. What automated tests I added (or what prevented me from doing so)

    • Updated an existing test

PR Submission Checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Testing Checklist (strike-out the not-applying and unnecessary ones):

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • Talkback.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • Large and small screen sizes. (Tablet and smaller phones)
  • Multi-tasking: Split screen and Pop-up view. (Android 10 or higher)

@antonis antonis added this to the 24.7 milestone Apr 5, 2024
@dangermattic
Copy link
Collaborator

dangermattic commented Apr 5, 2024

1 Warning
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.

Generated by 🚫 Danger

@antonis
Copy link
Contributor Author

antonis commented Apr 5, 2024

Hey @irfano, @thomashorta 👋
I'm adding you as reviewers since you might have some context from previous work on the AppInitialiser. I plan to iterate on this PR next week and test it more before making it ready for review. Any early feedback is more than welcome 🙇

@antonis antonis requested review from irfano and thomashorta April 5, 2024 15:09
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Apr 5, 2024

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr20603-968cc5a
Commit968cc5a
Direct Downloadwordpress-prototype-build-pr20603-968cc5a.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Apr 5, 2024

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr20603-968cc5a
Commit968cc5a
Direct Downloadjetpack-prototype-build-pr20603-968cc5a.apk
Note: Google Login is not supported on these builds.

Copy link

codecov bot commented Apr 8, 2024

Codecov Report

Attention: Patch coverage is 9.09091% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 40.40%. Comparing base (d1577bb) to head (968cc5a).

Files Patch % Lines
.../main/java/org/wordpress/android/AppInitializer.kt 0.00% 3 Missing ⚠️
...rg/wordpress/android/ui/blaze/BlazeFeatureUtils.kt 0.00% 2 Missing ⚠️
...a/org/wordpress/android/ui/media/ExoPlayerUtils.kt 0.00% 2 Missing ⚠️
...i/sitecreation/plans/SiteCreationPlansViewModel.kt 0.00% 2 Missing ⚠️
...rdpress/android/ui/sitemonitor/SiteMonitorUtils.kt 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #20603   +/-   ##
=======================================
  Coverage   40.39%   40.40%           
=======================================
  Files        1474     1474           
  Lines       67920    67911    -9     
  Branches    11231    11230    -1     
=======================================
- Hits        27438    27437    -1     
+ Misses      38000    37992    -8     
  Partials     2482     2482           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

sonarqubecloud bot commented Apr 8, 2024

Quality Gate Passed Quality Gate passed

Issues
5 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@antonis antonis requested a review from jarvislin April 8, 2024 09:11
@antonis antonis marked this pull request as ready for review April 8, 2024 09:16
@antonis antonis requested a review from a team as a code owner April 8, 2024 09:16
Copy link

sentry-io bot commented Apr 9, 2024

Sentry Issue: JETPACK-ANDROID-P8V

Copy link
Member

@irfano irfano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Thank you for implementing this change. I conducted a smoke test on the app, and everything seems to be in order. ✅ It makes sense to move the userAgent to a single place and make it Singleton in AppConfigModule. The diff looks safe to me. Feel free to merge the PR if you believe a single approval is sufficient.

@antonis
Copy link
Contributor Author

antonis commented Apr 11, 2024

Thank you for reviewing @irfano 🙇

Feel free to merge the PR if you believe a single approval is sufficient.

I'm not sure if this PR fixes the issue but I feel confident with the introduced changes and I'll proceed with merging. I'll monitor the 24.7 beta rollout for any unexpected side effects and to check if the fix worked.

@antonis antonis merged commit e7e332d into trunk Apr 11, 2024
25 of 26 checks passed
@antonis antonis deleted the fix/12259-userAgent branch April 11, 2024 07:24
Copy link

sentry-io bot commented Apr 11, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ ApplicationNotResponding: Background ANR org.wordpress.android.util.PackageUtils in getP... View Issue
  • ‼️ ApplicationNotResponding: Background ANR org.wordpress.android.fluxc.network.UserAgent i... View Issue
  • ‼️ ApplicationNotResponding: Background ANR org.wordpress.android.fluxc.network.UserAgent i... View Issue
  • ‼️ ApplicationNotResponding: Background ANR org.wordpress.android.fluxc.network.UserAgent i... View Issue
  • ‼️ ApplicationNotResponding: Background ANR org.wordpress.android.fluxc.network.UserAgent i... View Issue

Did you find this useful? React with a 👍 or 👎

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

Successfully merging this pull request may close these issues.

ApplicationNotResponding in UserAgent
4 participants