Fix Sentry 1GDC/1GEB/1GAF/1G8Z: move Reader DB writes off main thread#22861
Open
nbradbury wants to merge 2 commits into
Open
Fix Sentry 1GDC/1GEB/1GAF/1G8Z: move Reader DB writes off main thread#22861nbradbury wants to merge 2 commits into
nbradbury wants to merge 2 commits into
Conversation
… 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>
Collaborator
Generated by 🚫 Danger |
Contributor
|
|
Contributor
|
|
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
…er-volley-db-writes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Fixes a cluster of Reader ANRs where Volley response callbacks ran a SQLite
compileStatement+executeon the main thread:ReaderTagTable.updateTagLastUpdated(17 users)ReaderBlogTable.addOrUpdateBlog(13 users)Volley's
ResponseDeliveryRunnableruns callbacks on the main thread. When the SQLite connection pool is busy with concurrent writes (Reader sync), parking onacquireConnectionfrom the main thread tipped these calls over the 5s ANR threshold.Changes
ReaderPostRepository.kt— bothsetTagLastUpdated(tag)call sites (requestPostsWithTag,requestPostsForLatestStream) now run on a backgroundThread, matching the existing pattern inhandleUpdatePostsResponse.ReaderBlogActions.java—handleUpdateBlogInfoResponsenow performsaddOrUpdateBlogon a backgroundThreadand postsUpdateBlogInfoListener.onResultback on the main thread viaHandler(Looper.getMainLooper()). The two existing callers (ReaderSiteHeaderView,ReaderFetchSiteUseCase) expect the result on main —ReaderSiteHeaderViewcallsisAttachedToWindow()and updates views in the callback.Test plan