-
Notifications
You must be signed in to change notification settings - Fork 65
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
App crashes if parser uses a regex that is used in another worklet #574
App crashes if parser uses a regex that is used in another worklet #574
Comments
@s77rt Thanks for reporting this issue. I can see why using the same regex object in However, I'm not sure if this is the same bug as reported in Expensify/App#52475. Note that PR enabling worklets in |
The bug in Expensify/App#52475 is different. I faced the crash while trying to update |
So the fix is in |
Correct! The needed version is 2.0.108 |
Alright, so we bumped Maybe we should have released worklet support as 0.2.0 so we can keep 0.1.x versions with old engine. Sorry for inconvenience, we don't have much control over versioning scheme as the bot bumps the version in package.json and publishes to npm automatically. |
I think I will just avoid the problem. I doubt we need regex in worklets in E/App. It's being captured only because we reference a value that comes from an object |
Okay, in that case I'll leave the fix in E/App up to you. I will investigate the issue as it's probably rooted in reanimated/worklets. |
I found the root cause of the issue. In Reanimated/Worklets, The C++ implementation of |
Thank you! |
@s77rt Here's the fix in reanimated: software-mansion/react-native-reanimated#6796 |
FYI @s77rt I will be bumping (or trying to 😅) live-markdown to the worklet supporting version, and |
…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>
…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>
…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>
…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>
…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>
…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>
Using same regex (or objects that contain regex) in multiple worklets causes a crash. This is possibly a bug in react-native-reanimated but I'm not sure. cc @tomekzaw You may have an idea on this
Reproducible example:
The text was updated successfully, but these errors were encountered: