Skip to content

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

Draft
nbradbury wants to merge 1 commit into
trunkfrom
fix/sentry-1g8p-reader-pager-tracking
Draft

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

Conversation

@nbradbury
Copy link
Copy Markdown
Contributor

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).
  • Rotate the device while paging — lifecycleScope should cancel pending work cleanly without a leak.

🤖 Generated with Claude Code

…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

1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Copy Markdown
Contributor

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-7e51cd6
Build Number1488
Application IDorg.wordpress.android.prealpha
Commit7e51cd6
Installation URL6nbraud2q1n58
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

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-7e51cd6
Build Number1488
Application IDcom.jetpack.android.prealpha
Commit7e51cd6
Installation URL1r5ufcdfm8s48
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

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