Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash caused by using
ShareableHandle
in multiple remote runtim…
…es (#6796) ## Summary Fixes Expensify/react-native-live-markdown#574. See root cause analysis in Expensify/react-native-live-markdown#574 (comment). This PR fixes a crash caused by calling `ShareableHandle::toJSValue` with second remote runtime after initializing `remoteValue_` with a `jsi::Value` belonging to the first remote runtime. I assume that this is a rare scenario so we only memoize the value for the first remote runtime and we recreate the value for all subsequent runtimes. ## Test plan Reproduction: <details> <summary>EmptyExample.tsx</summary> ```tsx import { Text, StyleSheet, View } from 'react-native'; import React from 'react'; import { createWorkletRuntime, runOnRuntime, useAnimatedStyle, } from 'react-native-reanimated'; const regex = /\d/; const workletRuntime = createWorkletRuntime('another'); export default function EmptyExample() { useAnimatedStyle(() => { console.log('useAnimatedStyle', String(regex)); return {}; }); runOnRuntime(workletRuntime, () => { 'worklet'; console.log('runOnRuntime', String(regex)); return {}; })(); return ( <View style={styles.container}> <Text>Hello world!</Text> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', }, }); ``` </details>
- Loading branch information