Skip to content

perf(Android): recycle replaced shadow bitmaps - #8360

Open
OskarEichler wants to merge 1 commit into
wix:masterfrom
OskarEichler:codex/recycle-shadow-bitmaps
Open

perf(Android): recycle replaced shadow bitmaps#8360
OskarEichler wants to merge 1 commit into
wix:masterfrom
OskarEichler:codex/recycle-shadow-bitmaps

Conversation

@OskarEichler

Copy link
Copy Markdown

Performance problem and fix

ShadowLayout regenerates its cached bitmap after layout/appearance changes. The previous bitmap was overwritten without being recycled, so each regeneration left its native pixel allocation for GC/finalization instead of releasing it deterministically. A full-screen-width shadow cache can make that churn substantial during repeated layout changes.

This change centralizes cache teardown:

  • detach the bitmap from the reusable Canvas
  • recycle and clear the previous cache before replacement
  • use the same cleanup when the view detaches
  • mark the shadow dirty after detach so a reattached view rebuilds its cache

The temporary alpha bitmap was already recycled and remains unchanged.

Regression coverage

The new Robolectric test renders a shadow, invalidates layout, renders again, and verifies the first bitmap was recycled before the replacement became active. The exact baseline leaves it unrecycled.

Verification

  • focused regression: 1/1 passed
  • full Android unit suite: 698 passed, 2 skipped, 0 failed
  • Android debug Kotlin/Java compilation passed
  • git diff --check passed

Breaking changes

None. Rendering output is unchanged; native bitmap memory is released promptly.

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