Skip to content

Fix Sentry 1G11/1GB0/1GAA/1GCH/1GP0/1GZV/1GN4: async Reader paging count query#22863

Merged
nbradbury merged 3 commits into
trunkfrom
fix/sentry-1g11-reader-paging-count
May 19, 2026
Merged

Fix Sentry 1G11/1GB0/1GAA/1GCH/1GP0/1GZV/1GN4: async Reader paging count query#22863
nbradbury merged 3 commits into
trunkfrom
fix/sentry-1g11-reader-paging-count

Conversation

@nbradbury
Copy link
Copy Markdown
Contributor

@nbradbury nbradbury commented May 13, 2026

Summary

Fixes a cluster of Reader list ANRs where ReaderPostListFragment.dataRequestedListener.onRequestData ran a SQLite count query on the main thread from RecyclerView's GapWorker (prefetch path):

When the SQLite connection pool was busy with concurrent Reader writes, the prefetch-driven count query parked on acquireConnection long enough to exceed the ANR budget.

Changes

onRequestData now runs inside viewLifecycleOwner.lifecycleScope.launch. The SQL count queries (getNumPostsWithTag, getNumPostsInFeed, getNumPostsInBlog) move to withContext(Dispatchers.IO); the resulting updatePostsWithTag / updatePostsInCurrentBlogOrFeed / updatePostsInCurrentSearch calls and the READER_INFINITE_SCROLL track call run back on main, since they touch activity and start a FluxC service.

The early if (isUpdating) return short-circuit is preserved to avoid scheduling redundant coroutines.

Test plan

  • Open the Reader Following / Tag streams and scroll past the bottom
  • Run a Reader search and scroll past the bottom — same behavior.
  • Pull-to-refresh while scrolling — no UI jank or ANR.

…Reader paging count

ReaderPostListFragment.dataRequestedListener.onRequestData was invoked by
RecyclerView's GapWorker on the main thread and ran ReaderPostTable.
getNumPostsWithTag/getNumPostsInFeed/getNumPostsInBlog synchronously.
On a busy SQLite connection pool the count query parked long enough to
trip the ANR threshold.

Move the count queries to Dispatchers.IO inside
viewLifecycleOwner.lifecycleScope.launch and only resume on main to fire
the existing updatePosts* calls (which start the FluxC service and need
the activity context).

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 Jetpack Android by scanning the QR code below to install the corresponding build.

App NameJetpack Android
Build TypeDebug
Versionpr22863-32038ad
Build Number1488
Application IDcom.jetpack.android.prealpha
Commit32038ad
Installation URL4mjm8gr6ka7ug
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 WordPress Android by scanning the QR code below to install the corresponding build.

App NameWordPress Android
Build TypeDebug
Versionpr22863-32038ad
Build Number1488
Application IDorg.wordpress.android.prealpha
Commit32038ad
Installation URL6mg72c86n71i8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

nbradbury and others added 2 commits May 19, 2026 09:54
Avoids a race where the count query uses one tag and the follow-up
updatePostsWithTag uses a different one if the user switches tags
while the IO read is in flight.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@nbradbury nbradbury requested a review from adalpari May 19, 2026 14:38
@nbradbury nbradbury marked this pull request as ready for review May 19, 2026 14:38
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 19, 2026 16:09
@nbradbury nbradbury merged commit 076015c into trunk May 19, 2026
26 of 28 checks passed
@nbradbury nbradbury deleted the fix/sentry-1g11-reader-paging-count branch May 19, 2026 16:18
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