makeImageSnapshot crashes Android app
Description
See Snack for reference code
When invoking makeImageSnapshot directly when a component loads, directly an snapshot is captured from the visible canvas using the useAnimatedReaction hook. However, the app crashes immediately. In sentry I can see that it is a segmentation fault.
When I am running makeImageSnapshot after trigger it by a separate button at a later moment, the app doesn't crash.
Version
1.3.9
Steps to reproduce
Run example with and without line 54 commented out.
Snack, code example, screenshot, or link to a repository
this snack was tested using a development build in a local repo instead, due to the dependencies
I believe I'm encountering the same issue on iOS. It seems to me that the issue is with the API — there's no way to tell when the Skia view has finished rendering. If I do this:
const handleLayout = () => {
const image = canvasRef.current?.makeImageSnapshot()
}
return (
<Canvas
ref={canvasRef}
onLayout={handleLayout}
/>
)
It seems like there's a race condition — sometimes the snapshot is taken successfully, other times the app crashes with a "no Skia view available" error. It seems like all I can do is wrap the makeImageSnapshot in a timeout.
This should be fixed in v1.6.0, if not please let me know.