Skip to content

RUM-10346: Avoid copying hardware bitmap in Session Replay#2732

Merged
ambushwork merged 1 commit into
developfrom
yl/sr/avoid-copying-hardware-bitmap
Jun 17, 2025
Merged

RUM-10346: Avoid copying hardware bitmap in Session Replay#2732
ambushwork merged 1 commit into
developfrom
yl/sr/avoid-copying-hardware-bitmap

Conversation

@ambushwork

Copy link
Copy Markdown
Member

What does this PR do?

In Session Replay especially for Jetpack Compose, we are copying the original bitmap before compressing and transforming it into byte data on work thread in case that the original one is recycled.

But copying hardware bitmap can be very slow especially we are doing it on main thread. With some manual test we noticed that the average copy time of software bitmap is around 30~60us, and for hardware bitmap it can be up to 10~20ms. And it throws strict mode warning if client enables it in their app.

So in this PR we decide to skip hardware bitmap copying, passing the original instance until the byte data processing, if it is recycled during the time, then we skip it by reporting it to telemetry.

Motivation

RUM-10346:

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@codecov-commenter

codecov-commenter commented Jun 16, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 16.66667% with 15 lines in your changes missing coverage. Please review.

Project coverage is 69.76%. Comparing base (c13cf84) to head (821b386).

Files with missing lines Patch % Lines
...ionreplay/compose/internal/utils/SemanticsUtils.kt 16.67% 12 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2732      +/-   ##
===========================================
- Coverage    69.83%   69.76%   -0.07%     
===========================================
  Files          824      824              
  Lines        30774    30791      +17     
  Branches      5173     5177       +4     
===========================================
- Hits         21489    21479      -10     
- Misses        7823     7850      +27     
  Partials      1462     1462              
Files with missing lines Coverage Δ
...ionreplay/compose/internal/utils/SemanticsUtils.kt 64.92% <16.67%> (-5.19%) ⬇️

... and 36 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ambushwork
ambushwork marked this pull request as ready for review June 17, 2025 08:42
@ambushwork
ambushwork requested review from a team as code owners June 17, 2025 08:42
@aleksandr-gringauz

Copy link
Copy Markdown
Contributor

Didn't we stop copying bitmap in main thread in this pr?

@ambushwork

Copy link
Copy Markdown
Member Author

Didn't we stop copying bitmap in main thread in this pr?

That PR is the fix for copying the drawable, it only applies to Android classic view since we can't access to drawable directly in Jetpack Compose, This PR fixes the bitmap copy issue when we retrieve the bitmap by using reflection in Jetpack Compose.

0xnm
0xnm previously approved these changes Jun 17, 2025
@ambushwork
ambushwork dismissed stale reviews from aleksandr-gringauz and 0xnm via d99bf3a June 17, 2025 12:11
@ambushwork
ambushwork force-pushed the yl/sr/avoid-copying-hardware-bitmap branch from 4675f58 to d99bf3a Compare June 17, 2025 12:11
@ambushwork
ambushwork force-pushed the yl/sr/avoid-copying-hardware-bitmap branch from d99bf3a to 4edd2af Compare June 17, 2025 12:22
@ambushwork
ambushwork force-pushed the yl/sr/avoid-copying-hardware-bitmap branch from 4edd2af to 1b2f389 Compare June 17, 2025 12:39
@ambushwork
ambushwork force-pushed the yl/sr/avoid-copying-hardware-bitmap branch from 1b2f389 to 821b386 Compare June 17, 2025 14:05
@ambushwork
ambushwork merged commit c7ab9b6 into develop Jun 17, 2025
25 checks passed
@ambushwork
ambushwork deleted the yl/sr/avoid-copying-hardware-bitmap branch June 17, 2025 15:11
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.

4 participants