EXC_BAD_ACCESS on iOS when reloading the app while a value is being animated
Description
When animating a value on the Canvas, the app crashes after I press "r" to reload. If I remove the animated value from the rect shared value, the app doesn't crash.
I'm using Reanimated version 4.1.0.
Unsure if this is something that could trigger in a production build, but to me it's worrisome - and it also makes for a bad developer experience.
React Native Skia Version
2.2.21
React Native Version
0.81.4
Using New Architecture
- [x] Enabled
Steps to Reproduce
const animated = useSharedValue(1)
const size = useSharedValue({ width: 200, height: 200 })
const rect = useDerivedValue(() => {
const { width, height } = size.get()
return { x: 0, y: 0, width: width * animated.get(), height }
})
useAnimatedReaction(
() => size.get(),
() => {
cancelAnimation(animated)
animated.value = withRepeat(withTiming(0, { duration: 1000 }), -1)
},
)
return (
<Canvas style={styles.canvas}>
<Rect rect={rect} />
</Canvas>
)
Press 'R' to reload the simulator. Most time it crashes on first attempt. Some times on the second reload.
Snack, Code Example, Screenshot, or Link to Repository
+1
also getting this in production
+0x11becd0
std::__1::shared_ptr<T>::operator->[abi:ne200100] (shared_ptr.h:634)
+0x11becd0
RNSkia::RNSkView::getScaledWidth (RNSkView.h:211)
+0x11becd0
RNSkia::RNSkJsiViewApi::setJsiProperty::lambda::operator() (RNSkJsiViewApi.h:109)
+0x11beb00
RNSkia::ViewRegistry::withViewInfo<T> (RNSkJsiViewApi.h:56)
+0x11bdab8
RNSkia::RNSkJsiViewApi::setJsiProperty (RNSkJsiViewApi.h:102)
+0x0036d6c
std::__1::__function::__value_func<T>::operator()[abi:ne200100] (function.h:436)
+0x0036d6c
std::__1::function<T>::operator() (function.h:995)
+0x0036d6c
std::__1::__function::__value_func<T>::operator()[abi:ne200100] (function.h:436)
+0x0036d6c
std::__1::function<T>::operator() (function.h:995)
hermes
+0x0013890
std::__1::function<T>::operator()
@wotaso @onelittlebird this crash has been fixed in v2.3.12 and above. I hope this help. I'm closing this for now as completed but please keep me posted.
@wotaso @onelittlebird this crash has been fixed in v2.3.12 and above. I hope this help. I'm closing this for now as completed but please keep me posted.
i experienced it also in 2.4.7 / 2.4.6 couldnt replicate this error in expo dev client, it only happened in production. (IOS)
for now i switched from "onSize" prop to using js layout data
the code pointed out in the crash doesn't exist anymore, nor do we do anything related to onSize anymore: we ask Reanimated to give us the size instead: https://github.com/Shopify/react-native-skia/blob/main/packages/skia/src/renderer/Canvas.tsx#L116 If you have more information about this crash, I'd be happy to take a look