fix(replay): Post checkCanRecord to main thread to prevent deadlock#5837
Open
romtsn wants to merge 3 commits into
Open
fix(replay): Post checkCanRecord to main thread to prevent deadlock#5837romtsn wants to merge 3 commits into
romtsn wants to merge 3 commits into
Conversation
onScreenshotRecorded can run on the replay executor thread (PixelCopy masked-capture and emit paths). checkCanRecord -> pauseInternal acquires lifecycleLock — if another thread holds that lock and submits to the same single-threaded executor, we deadlock. Post checkCanRecord to the main looper so it never runs on the executor. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
romtsn
requested review from
0xadam-brown,
adinauer,
markushi and
runningcode
as code owners
July 24, 2026 15:38
romtsn
added a commit
that referenced
this pull request
Jul 24, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a4cab2c. Configure here.
📲 Install BuildsAndroid
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 22f4345 | 307.87 ms | 354.51 ms | 46.64 ms |
| 8c7718c | 307.42 ms | 374.84 ms | 67.42 ms |
| bb0ff41 | 321.00 ms | 378.28 ms | 57.28 ms |
| c8125f3 | 397.65 ms | 485.14 ms | 87.49 ms |
| eb95ded | 317.51 ms | 369.08 ms | 51.57 ms |
| f634d01 | 375.06 ms | 420.04 ms | 44.98 ms |
| 9fbb112 | 359.71 ms | 421.85 ms | 62.14 ms |
| d501a7e | 307.33 ms | 341.94 ms | 34.61 ms |
| bb0ff41 | 317.76 ms | 384.66 ms | 66.90 ms |
| 9054d65 | 330.94 ms | 403.24 ms | 72.30 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 22f4345 | 1.58 MiB | 2.29 MiB | 719.83 KiB |
| 8c7718c | 0 B | 0 B | 0 B |
| bb0ff41 | 0 B | 0 B | 0 B |
| c8125f3 | 1.58 MiB | 2.10 MiB | 532.32 KiB |
| eb95ded | 0 B | 0 B | 0 B |
| f634d01 | 1.58 MiB | 2.10 MiB | 533.40 KiB |
| 9fbb112 | 1.58 MiB | 2.11 MiB | 539.18 KiB |
| d501a7e | 0 B | 0 B | 0 B |
| bb0ff41 | 0 B | 0 B | 0 B |
| 9054d65 | 1.58 MiB | 2.29 MiB | 723.38 KiB |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
romtsn
force-pushed
the
rz/fix/replay-checkcanrecord-deadlock
branch
from
July 24, 2026 17:51
a4cab2c to
0f1e537
Compare
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
onScreenshotRecordedcan run on the replay executor thread (PixelCopy masked-capture and emit paths).checkCanRecord()→pauseInternal()acquireslifecycleLock— if another thread holds that lock and submits to the same single-threaded executor, we deadlock.checkCanRecord()to the main looper so it never runs on the executor thread.This was a pre-existing issue introduced with SurfaceView capturing (masked-capture path calls
onScreenshotRecordedfrom executor atPixelCopyStrategy.kt:209), and is also relevant for PR #5808 which adds theemitLastScreenshotexecutor path.Test plan
onScreenshotRecorded pauses replay when rate-limited for sessionstest updated to idle looper./gradlew :sentry-android-replay:testReleaseUnitTest --tests="*ReplayIntegrationTest*"passes🤖 Generated with Claude Code