Skip to content
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

makeImageSnapshot crashes Android app #2559

Open
Laityned opened this issue Aug 1, 2024 · 1 comment
Open

makeImageSnapshot crashes Android app #2559

Laityned opened this issue Aug 1, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Laityned
Copy link

Laityned commented Aug 1, 2024

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

@Laityned Laityned added the bug Something isn't working label Aug 1, 2024
@stevengoldberg
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants