Show disable-remote-verify snackbar on UI thread#332
Merged
thestinger merged 1 commit intoGrapheneOS:mainfrom Apr 29, 2026
Merged
Conversation
The Snackbar update in the disable_remote_verify dialog handler runs on RemoteVerifyJob.executor (a single-threaded background executor), unlike the snackbar updates in the surrounding clear_auditee / clear_auditor handlers which are correctly wrapped in runOnUiThread. Touching a View off the UI thread is incorrect by Android's contract and can throw CalledFromWrongThreadException via View.requestLayout() when the Snackbar's view is currently attached (e.g. another snackbar is still visible from a prior action). Wrap the call in runOnUiThread to match the other handlers.
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
In
AttestationActivity#onOptionsItemSelected, theR.id.action_disable_remote_verifyhandler updates theSnackbarfromRemoteVerifyJob.executor(a single-threaded background executor):This is inconsistent with the surrounding
action_clear_auditeeandaction_clear_auditorhandlers in the same method, both of which correctly wrap the snackbar update inrunOnUiThread(...).Why it matters
Snackbar.setText(int)ultimately callsTextView.setText(...)→checkForRelayout()→View.requestLayout(). When the snackbar's view is attached to a window,requestLayout()invokesViewRootImpl.checkThread(), which throwsCalledFromWrongThreadExceptionfrom any non-UI thread.In the common case the previous snackbar has already been dismissed by the time the disable flow finishes, so the call happens to not crash — but it is incorrect by Android's contract regardless, and it will crash when another snackbar is still visible (e.g. the user re-opens the menu after a recent action). Touching
Viewstate off the UI thread is also racy with respect to fields read by the UI thread.Fix
Wrap the call in
runOnUiThread(...)to match the other two handlers in the same method. One-line change.Regression introduced in
ee842c4 "improve user feedback for background tasks"
(2022-09-12). The same commit correctly wrapped the equivalentclearAuditeeandclearAuditorsnackbar updates inrunOnUiThread; thedisable_remote_verify` branch was edited differently and just moved the existing snackbar call into the executor lambda without the wrapper.