Skip to content

Fix Sentry 1G8P/1FWW/1GSX/1G4S/1GC3/1GB9: track Reader posts off main thread#22862

Open
nbradbury wants to merge 3 commits into
trunkfrom
fix/sentry-1g8p-reader-pager-tracking
Open

Fix Sentry 1G8P/1FWW/1GSX/1G4S/1GC3/1GB9: track Reader posts off main thread#22862
nbradbury wants to merge 3 commits into
trunkfrom
fix/sentry-1g8p-reader-pager-tracking

Conversation

@nbradbury
Copy link
Copy Markdown
Contributor

@nbradbury nbradbury commented May 13, 2026

Summary

Fixes a cluster of Reader pager ANRs where ReaderPostPagerActivity.trackPostAtPositionIfNeeded performed two ReaderPostTable.getBlogPost (rawQuery) calls synchronously on the main thread from a Handler.postDelayed:

When the SQLite connection pool was busy (Reader sync) the rawQuery parked on acquireConnection long enough to trip the 5s ANR threshold.

Changes

ReaderPostPagerActivity.trackPost now runs inside lifecycleScope.launch(Dispatchers.IO). The collaborators it calls are all thread-safe:

  • ReaderPostActions.bumpPageViewForPost — queues a Volley request.
  • ReaderPostSeenStatusWrapper.markPostAsSeenSilently — already launches its own coroutine on BG_THREAD.
  • ReaderTracker.trackPost — forwards to AnalyticsTracker.

No UI code runs in the moved block, so dispatching to IO is safe.

Test plan

  • Open a Reader post from the discover/tag stream and swipe through several posts; confirm posts open and "seen" state updates as expected.
  • Confirm READER_ARTICLE_OPENED analytics still fire for each newly viewed post (check Tracks/console).

…r posts off main

trackPostAtPositionIfNeeded ran ReaderPostTable.getBlogPost (rawQuery)
twice on the main thread from a Handler.postDelayed in the pager. With
a busy SQLite connection pool this exceeded the ANR budget.

Wrap trackPost in lifecycleScope.launch(Dispatchers.IO) so the DB reads,
the Volley page-view ping, and the analytics call all run off-main. The
existing collaborators are already thread-safe:
- bumpPageViewForPost queues a Volley request.
- markPostAsSeenSilently launches its own coroutine.
- readerTracker.trackPost only forwards to AnalyticsTracker.

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

dangermattic commented May 13, 2026

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

Generated by 🚫 Danger

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented May 13, 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
Versionpr22862-acfe17b
Build Number1488
Application IDorg.wordpress.android.prealpha
Commitacfe17b
Installation URL4en1if9s4p2l8
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 13, 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
Versionpr22862-acfe17b
Build Number1488
Application IDcom.jetpack.android.prealpha
Commitacfe17b
Installation URL0hpifhpombsg0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@nbradbury nbradbury marked this pull request as ready for review May 18, 2026 16:26
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.

3 participants