Skip to content

Commit

Permalink
Clear operationsInBatch_ before terminating UI runtime (#6779)
Browse files Browse the repository at this point in the history
## Summary

This PR fixes the following crash that happens during a reload due to
`jsi::Value` outliving the UI runtime.

The offending `jsi::Value` comes from `operationsInBatch_` inside
`ReanimatedModuleProxy` (formerly `NativeReanimatedModule`.

In `~ReanimatedModuleProxy` we manually clear data structures containing
`jsi::Value` prior to resetting `uiWorkletRuntime_` which effectively
terminates the runtimes. It looks like we forgot about
`operationsInBatch_`.

<img width="1624" alt="Screenshot 2024-12-02 at 13 00 08"
src="https://github.com/user-attachments/assets/23c8df28-885e-45e7-b88c-779edc3c4fb5">

## Test plan

1. Launch FabricExample app
2. Reload the app several times
3. Repeat steps 1 and 2 several times
  • Loading branch information
tomekzaw committed Dec 9, 2024
1 parent d94a8a7 commit b97ba4f
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ NativeReanimatedModule::~NativeReanimatedModule() {
// runtime, so they have to go away before we tear down the runtime
eventHandlerRegistry_.reset();
frameCallbacks_.clear();
#ifdef RCT_NEW_ARCH_ENABLED
operationsInBatch_.clear();
#endif // RCT_NEW_ARCH_ENABLED
uiWorkletRuntime_.reset();
}

Expand Down

0 comments on commit b97ba4f

Please sign in to comment.