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

Fix crashes in android when removing/recreating views and surfaces #70

Merged
merged 3 commits into from
Dec 30, 2021

Conversation

chrfalch
Copy link
Collaborator

@chrfalch chrfalch commented Dec 24, 2021

Problem(s)

On Android there is a bug in the viewManager where the nativeId and view was stored as private variables in the manager. This is of course totally wrong - since a view manager manages multiple views.

In addition the Android view crashes from time to time after it is removed in the drawFrame method, and it is currently not possible for a view to continue redrawing after its underlying surface has been removed/recreated,

Solutions

This PR fixes this ViewManager issue by storing a map of views and nativeIds instead of the private variables.

It also contains a fix to the drawFrame method so that it checks to see if the view is removed before drawing.

A check for a nullptr has been added to the ensureSkiaRenderTarget in the´JniSkiaDrawView` class to make sure a view can have its underlying texture surface destroyed and recreated without the view crashing.

Fixes #15

When the surface is invalidated (view is not visible) and the surface is available again, the skia surface needs to be recreated. Added a test to check for null _skSurface when surface is available.
@ghost ghost added the cla-needed label Dec 24, 2021
@chrfalch chrfalch changed the title Bugfix/15 fix android viewmanager Fix crashes in android when removing/recreating views and surfaces Dec 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android crashes when skia views are removed
2 participants