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: Crash on UI Scheduling with invalidated WorkletsModuleProxy #6893

Closed
wants to merge 1 commit into from

Conversation

tjzel
Copy link
Collaborator

@tjzel tjzel commented Jan 13, 2025

Summary

When React Native is destroyed on reload, it runs the destructors for Native Modules on the JavaScript thread. Therefore, even though React Native instance is being destroyed, UI thread can still perform operations on the UI runtime. This leads to a crash where scheduleOnUI is called from the UI thread when WorkletsModuleProxy destructor has already released uiWorkletRuntime.

To fix this, I'm adding a simple shared mutex. WorkletsModuleProxy can be cleaned up only when no scheduling takes place and scheduling cannot be performed after WorkletsModuleProxy was invalidated.

Test plan

Try reloading Android now and see that it doesn't crash on scheduleOnUI anymore.

@tjzel tjzel requested review from tomekzaw and piaskowyk January 13, 2025 17:58
@tjzel
Copy link
Collaborator Author

tjzel commented Jan 14, 2025

@tjzel tjzel closed this Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant