-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Fix crash when drawing shadow on image using RenderNode #2635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crash when drawing shadow on image using RenderNode #2635
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.
Draft for now as I would like to add a repro test case. |
*/ | ||
public boolean finishDecrementsCanvasSaveCount() { | ||
// endRecording() will decrement the save count of the Canvas returned by beginRecording() | ||
return currentStrategy == RenderStrategy.RENDER_NODE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geomaster I'm not sure why this happens, but I narrowed down the beginRecording()
/endRecording()
interaction as the root cause of the underflow error.
For reference my repro code is as follows:
|
|
||
internal fun SnapshotTestCaseContext.getBitmapFromAssets(name: String): Bitmap { | ||
return BitmapFactory.decodeStream(context.assets.open(name), null, BitmapFactory.Options())!! | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this utility function so it can be shared
When using the RenderNode rendering strategy, the call to
OffscreenLayer.finish()
decrements the save count on theCanvas
returned fromOffscreenLayer.start()
, so we need to know whether to skip the call toCanvas.restore()
inImageLayer
, otherwise theCanvas
will throw an exception.Fixes #2609