Skip to content

perf(replay): Use RGB_565 when alpha is unnecessary#5821

Draft
romtsn wants to merge 2 commits into
rz/fix/pixelcopy-frame-racefrom
rz/perf/use-rgb565-for-replay
Draft

perf(replay): Use RGB_565 when alpha is unnecessary#5821
romtsn wants to merge 2 commits into
rz/fix/pixelcopy-frame-racefrom
rz/perf/use-rgb565-for-replay

Conversation

@romtsn

@romtsn romtsn commented Jul 22, 2026

Copy link
Copy Markdown
Member

📜 Description

Use RGB_565 for replay recording bitmaps when alpha is unnecessary. PixelCopy keeps
ARGB_8888 when SurfaceView capture is enabled because compositing depends on the transparent
holes left in the Window capture. Canvas capture always uses RGB_565 because it does not support
SurfaceView compositing.

This PR depends on #5808.

💡 Motivation and Context

RGB_565 halves the recording bitmap's memory footprint. The previous switch to ARGB_8888 was
based on an unconfirmed theory about native bitmap crashes; #5808 instead addresses the concurrent
PixelCopy access and recycling that can produce those crashes.

Refs #5340

💚 How did you test it?

  • ./gradlew ':sentry-android-replay:testDebugUnitTest' --tests='*PixelCopyStrategyTest*' --info
  • ./gradlew spotlessApply apiDump

Added assertions that regular PixelCopy capture uses RGB_565 and SurfaceView capture retains
ARGB_8888.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

None.

Reduce replay screenshot memory while retaining ARGB_8888 for SurfaceView compositing.

Refs GH-5340
Co-Authored-By: Codex <noreply@openai.com>
@github-actions

Copy link
Copy Markdown
Contributor
Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Performance

- Use RGB_565 when alpha is unnecessary ([#5821](https://github.com/getsentry/sentry-java/pull/5821))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 6b3a39d

@sentry

sentry Bot commented Jul 22, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

@github-actions

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 327.98 ms 377.96 ms 49.98 ms
Size 0 B 0 B 0 B

Baseline results on branch: rz/fix/pixelcopy-frame-race

Startup times

Revision Plain With Sentry Diff
fab3793 330.67 ms 352.10 ms 21.43 ms
fcda53a 318.75 ms 365.57 ms 46.82 ms
1976346 313.33 ms 371.69 ms 58.35 ms

App size

Revision Plain With Sentry Diff
fab3793 0 B 0 B 0 B
fcda53a 0 B 0 B 0 B
1976346 0 B 0 B 0 B

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