Fix crash when drawing shadow on image using RenderNode#2635
Merged
gpeal merged 2 commits intoairbnb:masterfrom May 27, 2025
Merged
Fix crash when drawing shadow on image using RenderNode#2635gpeal merged 2 commits intoairbnb:masterfrom
gpeal merged 2 commits intoairbnb:masterfrom
Conversation
When using the RenderNode rendering strategy, the call to `OffscreenLayer.finish()` decrements the save count on the `Canvas` returned from `OffscreenLayer.start()`, so we need to know whether to skip the call to `Canvas.restore()` in `ImageLayer`, otherwise the `Canvas` will thrown an exception.
Collaborator
Author
|
Draft for now as I would like to add a repro test case. |
allenchen1154
commented
May 19, 2025
| */ | ||
| public boolean finishDecrementsCanvasSaveCount() { | ||
| // endRecording() will decrement the save count of the Canvas returned by beginRecording() | ||
| return currentStrategy == RenderStrategy.RENDER_NODE; |
Collaborator
Author
There was a problem hiding this comment.
@geomaster I'm not sure why this happens, but I narrowed down the beginRecording()/endRecording() interaction as the root cause of the underflow error.
Collaborator
Author
|
For reference my repro code is as follows: |
allenchen1154
commented
May 20, 2025
|
|
||
| internal fun SnapshotTestCaseContext.getBitmapFromAssets(name: String): Bitmap { | ||
| return BitmapFactory.decodeStream(context.assets.open(name), null, BitmapFactory.Options())!! | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
Moved this utility function so it can be shared
gpeal
approved these changes
May 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using the RenderNode rendering strategy, the call to
OffscreenLayer.finish()decrements the save count on theCanvasreturned fromOffscreenLayer.start(), so we need to know whether to skip the call toCanvas.restore()inImageLayer, otherwise theCanvaswill throw an exception.Fixes #2609