Skip to content

Conversation

@markushi
Copy link
Member

@markushi markushi commented Mar 28, 2025

📜 Description

Fixes #3647

💡 Motivation and Context

💚 How did you test it?

📝 Checklist

  • 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

@github-actions
Copy link
Contributor

github-actions bot commented Mar 28, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 393.94 ms 414.36 ms 20.42 ms
Size 1.58 MiB 2.08 MiB 505.47 KiB

Previous results on branch: markushi/fix/screenshot-anr

Startup times

Revision Plain With Sentry Diff
0e115b9 356.62 ms 415.47 ms 58.85 ms
ee4247a 382.23 ms 427.18 ms 44.95 ms

App size

Revision Plain With Sentry Diff
0e115b9 1.58 MiB 2.22 MiB 655.32 KiB
ee4247a 1.58 MiB 2.22 MiB 655.32 KiB

try (final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
// 0 meaning compress for small size, 100 meaning compress for max quality.
// Some formats, like PNG which is lossless, will ignore the quality setting.
bitmap.compress(Bitmap.CompressFormat.PNG, 0, byteArrayOutputStream);
Copy link
Member Author

Choose a reason for hiding this comment

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

It's worth mentioning that we never call bitmap.recycle() - and we also didn't do before. But I guess it makes sense to do so!

Copy link
Member

Choose a reason for hiding this comment

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

yeah, since we also create a new bitmap for every new screenshot we should probably recycle 😅

Copy link
Member

@romtsn romtsn left a comment

Choose a reason for hiding this comment

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

LGTM!

@markushi markushi merged commit 1e82a71 into main Apr 7, 2025
35 checks passed
@markushi markushi deleted the markushi/fix/screenshot-anr branch April 7, 2025 11:14
romtsn pushed a commit that referenced this pull request Jul 8, 2025
* Compress Screenshots on a background thread

* Update Changelog

* Recover APIs used by hybrid SDKs

* Recycle bitmap after compression
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.

ANR in Android from Screenshot

3 participants