Skip to content

fix(replay): Post checkCanRecord to main thread to prevent deadlock#5837

Open
romtsn wants to merge 3 commits into
mainfrom
rz/fix/replay-checkcanrecord-deadlock
Open

fix(replay): Post checkCanRecord to main thread to prevent deadlock#5837
romtsn wants to merge 3 commits into
mainfrom
rz/fix/replay-checkcanrecord-deadlock

Conversation

@romtsn

@romtsn romtsn commented Jul 24, 2026

Copy link
Copy Markdown
Member

Summary

  • 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 thread.

This was a pre-existing issue introduced with SurfaceView capturing (masked-capture path calls onScreenshotRecorded from executor at PixelCopyStrategy.kt:209), and is also relevant for PR #5808 which adds the emitLastScreenshot executor path.

Test plan

  • Existing onScreenshotRecorded pauses replay when rate-limited for sessions test updated to idle looper
  • ./gradlew :sentry-android-replay:testReleaseUnitTest --tests="*ReplayIntegrationTest*" passes

🤖 Generated with Claude Code

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 added a commit that referenced this pull request Jul 24, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread CHANGELOG.md Outdated
@sentry

sentry Bot commented Jul 24, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.50.0 (1) release

⚙️ sentry-android Build Distribution Settings

@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 327.07 ms 408.58 ms 81.52 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

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

Previous results on branch: rz/fix/replay-checkcanrecord-deadlock

Startup times

Revision Plain With Sentry Diff
ba152d2 346.75 ms 440.34 ms 93.59 ms

App size

Revision Plain With Sentry Diff
ba152d2 0 B 0 B 0 B

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@romtsn
romtsn force-pushed the rz/fix/replay-checkcanrecord-deadlock branch from a4cab2c to 0f1e537 Compare July 24, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant