Skip to content

Fix Sentry 1GDC/1GEB/1GAF/1G8Z: move Reader DB writes off main thread#22861

Open
nbradbury wants to merge 2 commits into
trunkfrom
fix/sentry-1gdc-reader-volley-db-writes
Open

Fix Sentry 1GDC/1GEB/1GAF/1G8Z: move Reader DB writes off main thread#22861
nbradbury wants to merge 2 commits into
trunkfrom
fix/sentry-1gdc-reader-volley-db-writes

Conversation

@nbradbury
Copy link
Copy Markdown
Contributor

@nbradbury nbradbury commented May 13, 2026

Summary

Fixes a cluster of Reader ANRs where Volley response callbacks ran a SQLite compileStatement + execute on the main thread:

Volley's ResponseDeliveryRunnable runs callbacks on the main thread. When the SQLite connection pool is busy with concurrent writes (Reader sync), parking on acquireConnection from the main thread tipped these calls over the 5s ANR threshold.

Changes

  • ReaderPostRepository.kt — both setTagLastUpdated(tag) call sites (requestPostsWithTag, requestPostsForLatestStream) now run on a background Thread, matching the existing pattern in handleUpdatePostsResponse.
  • ReaderBlogActions.javahandleUpdateBlogInfoResponse now performs addOrUpdateBlog on a background Thread and posts UpdateBlogInfoListener.onResult back on the main thread via Handler(Looper.getMainLooper()). The two existing callers (ReaderSiteHeaderView, ReaderFetchSiteUseCase) expect the result on main — ReaderSiteHeaderView calls isAttachedToWindow() and updates views in the callback.

Test plan

  • Open the Reader, refresh the feed and verify posts load
  • Pull-to-refresh repeatedly on a tag stream while scrolling — no UI jank or ANR.

… off main

Volley's ResponseDeliveryRunnable runs callbacks on the main thread, and
two Reader paths then performed a SQLite compileStatement + execute on
that callback. On a busy SQLite connection pool this exceeded the ANR
budget.

ReaderTagTable.setTagLastUpdated (called from
ReaderPostRepository.requestPostsWithTag and requestPostsForLatestStream)
now runs on a background Thread.

ReaderBlogActions.handleUpdateBlogInfoResponse now performs
ReaderBlogTable.addOrUpdateBlog on a background Thread and posts
UpdateBlogInfoListener.onResult back on the main thread, since the
existing callers (ReaderSiteHeaderView, ReaderFetchSiteUseCase) expect
the result on main.

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
Versionpr22861-0a5ec19
Build Number1488
Application IDorg.wordpress.android.prealpha
Commit0a5ec19
Installation URL0o3oofm1h5tc0
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
Versionpr22861-0a5ec19
Build Number1488
Application IDcom.jetpack.android.prealpha
Commit0a5ec19
Installation URL2lhi8ji6hivgo
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 13, 2026

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.22%. Comparing base (ba21502) to head (0a5ec19).

Files with missing lines Patch % Lines
...s/android/ui/reader/actions/ReaderBlogActions.java 0.00% 6 Missing ⚠️
...droid/ui/reader/repository/ReaderPostRepository.kt 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #22861      +/-   ##
==========================================
- Coverage   37.22%   37.22%   -0.01%     
==========================================
  Files        2318     2318              
  Lines      124561   124563       +2     
  Branches    16917    16917              
==========================================
  Hits        46371    46371              
- Misses      74440    74442       +2     
  Partials     3750     3750              

☔ 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 nbradbury marked this pull request as ready for review May 15, 2026 16:25
@nbradbury nbradbury requested a review from adalpari May 15, 2026 16:25
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