Skip to content

Fix Sentry WORDPRESS-ANDROID-3F23: guard preventBackNavigation#22838

Merged
nbradbury merged 5 commits intotrunkfrom
fix/sentry-3f23-preventbacknavigation
May 8, 2026
Merged

Fix Sentry WORDPRESS-ANDROID-3F23: guard preventBackNavigation#22838
nbradbury merged 5 commits intotrunkfrom
fix/sentry-3f23-preventbacknavigation

Conversation

@nbradbury
Copy link
Copy Markdown
Contributor

@nbradbury nbradbury commented May 6, 2026

Fixes WORDPRESS-ANDROID-3F23

Summary

Fix for Sentry WORDPRESS-ANDROID-3F23 — 32 users / 34 events. ActivityLauncherWrapper.preventBackNavigation calls Activity.finishAffinity() unconditionally, which throws IllegalStateException: Can not be called to deliver a result when the Activity is already finishing or destroyed.

Fix: skip the finishAffinity() call when the Activity is finishing or destroyed. The same fix also addresses the closely-related WORDPRESS-ANDROID-3F1V (18 users) which has identical culprit and stack.

Test plan

Eyeball the code - it's a simple, self-explanatory change. However, the purpose of the preventBackNavigation function was not self-explanatory, so I added a comment above it.

…t finished/destroyed Activity

Fixes WORDPRESS-ANDROID-3F23

ActivityLauncherWrapper.preventBackNavigation called Activity.finishAffinity()
unconditionally, which throws "IllegalStateException: Can not be called to
deliver a result" when the Activity is already finishing or destroyed (the
JetpackStaticPosterFragment click event arrives via SingleLiveEvent after
the Activity has been torn down).

Skip the finishAffinity() call when the Activity is finishing or destroyed.
The same fix also addresses the closely-related WORDPRESS-ANDROID-3F1V.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dangermattic
Copy link
Copy Markdown
Collaborator

dangermattic commented May 6, 2026

1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented May 6, 2026

App Icon📲 You can test the changes from this Pull Request in Jetpack Android by scanning the QR code below to install the corresponding build.

App NameJetpack Android
Build TypeDebug
Versionpr22838-971a5ff
Build Number1488
Application IDcom.jetpack.android.prealpha
Commit971a5ff
Installation URL31gk9rl61sg48
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented May 6, 2026

App Icon📲 You can test the changes from this Pull Request in WordPress Android by scanning the QR code below to install the corresponding build.

App NameWordPress Android
Build TypeDebug
Versionpr22838-971a5ff
Build Number1488
Application IDorg.wordpress.android.prealpha
Commit971a5ff
Installation URL436ocjbelriqg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.20%. Comparing base (6bef09a) to head (d19d2f3).

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #22838   +/-   ##
=======================================
  Coverage   37.20%   37.20%           
=======================================
  Files        2317     2317           
  Lines      124522   124522           
  Branches    16909    16909           
=======================================
  Hits        46333    46333           
  Misses      74441    74441           
  Partials     3748     3748           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

nbradbury and others added 3 commits May 6, 2026 14:25
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Cover the isFinishing and isDestroyed branches added to guard against the
IllegalStateException seen in WORDPRESS-ANDROID-3F23 / 3F1V.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@nbradbury nbradbury marked this pull request as ready for review May 7, 2026 16:20
@nbradbury nbradbury requested a review from adalpari May 7, 2026 18:01
Copy link
Copy Markdown
Contributor

@adalpari adalpari left a comment

Choose a reason for hiding this comment

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

LGTM!

@nbradbury nbradbury enabled auto-merge (squash) May 8, 2026 11:45
@nbradbury nbradbury merged commit a86b3ce into trunk May 8, 2026
21 of 23 checks passed
@nbradbury nbradbury deleted the fix/sentry-3f23-preventbacknavigation branch May 8, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants