react-native-reanimated
react-native-reanimated copied to clipboard
[iOS] Crash in MutableValue::set
Description
My app is crashing in production. It usually happens at app start. About every 5th app start will end in crash.
The stacktrace I get from crashlytics:
Crashed: com.apple.main-thread
0 pierre 0x27fd74 std::__1::__function::__func<reanimated::MutableValue::set(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&, facebook::jsi::Value const&)::$_2, std::__1::allocator<reanimated::MutableValue::set(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&, facebook::jsi::Value const&)::$_2>, void ()>::operator()() + 580 (shared_ptr.h:580)
1 pierre 0x2aa1e4 reanimated::Scheduler::triggerUI() + 463 (function.h:463)
2 libdispatch.dylib 0x63094 _dispatch_call_block_and_release + 24
3 libdispatch.dylib 0x64094 _dispatch_client_callout + 16
4 libdispatch.dylib 0x10d44 _dispatch_main_queue_drain + 928
5 libdispatch.dylib 0x10994 _dispatch_main_queue_callback_4CF$VARIANT$mp + 36
6 CoreFoundation 0x4e0d4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
7 CoreFoundation 0xb5f8 __CFRunLoopRun + 2544
8 CoreFoundation 0x1e250 CFRunLoopRunSpecific + 572
9 GraphicsServices 0x1988 GSEventRunModal + 160
10 UIKitCore 0x4e5a88 -[UIApplication _run] + 1080
11 UIKitCore 0x27efc8 UIApplicationMain + 336
12 pierre 0x9020 main + 14 (main.m:14)
13 ??? 0x105d344d0 (Missing)
Steps to reproduce
I can only catch it in debug when opening and closing app rapidly.
Snack or a link to a repository
Reanimated version
2.10
React Native version
0.68.2
Platforms
iOS
JavaScript runtime
Hermes
Workflow
React Native (without Expo)
Architecture
Paper (Old Architecture)
Build type
Release mode
Device
Real device
Device model
iPhone 13
Acknowledgements
Yes
Hey! 👋
It looks like you've omitted a few important sections from the issue template.
Please complete Snack or a link to a repository section.
Hey! 👋
The issue doesn't seem to contain a minimal reproduction.
Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?
Hey @DanijelBojcic, thanks for opening this issue.
Can you please prepare a minimal viable reproduction for this bug?
We're getting the same issue, randomly on release mode only, this is the crash from XCode:
Seems to be happening when unmounting a component running an animation.
Unfortunately I do not know how to reproduce it... One thing I've noticed is that it only happens on iOS 16.
Also maybe I should mention that we are using react-native-multithreading / react-native-vision-camera custom implementation for state management with MMKV, that notifies the JS if there is a change.
I assume the crash comes from rapidly calling reanimated::ShareableValue::adapt, when we call a JS callback from the JSI, which then makes other animations to fail ?? idk
I have no idea this is related to this. But it seems to this is not only iOS16 issue

I got the same crash on iPhone XR iOS 15.6.1, which does not reproduce consistently, and I did not use react-native-multithreading and react-native-vision-camera either.

we are seeing this issue as well iOS 16 only React Native version 68.5
Any Update on this?
I think we are seeing this too. For us, it was from the same JS migration that led to https://github.com/software-mansion/react-native-reanimated/issues/3917 (which contains a repro repository).
We didn't change our package versions at all - just migrated the JS API to use sharedValue and Gesture.Pan. The exact package versions and code sample are shown in the attached repro repository on that other issue.
After making this change, we started seeing EXC_BAD_ACCESS (attempted to dereference garbage pointer) in reanimated::Scheduler::triggerUI in our Sentry logs. We deployed this change to a small percentage of our traffic (about 3,000 users) and it affected 1.8% of them, which is severe enough that we'll need to roll back the change.
We've also seen a spike in OOM reports on iOS only, so maybe related to https://github.com/software-mansion/react-native-reanimated/issues/2824, but I don't have any strong evidence of that.
Same error here, cannot find the cause. Removed animations from the specific screen where it crashes (according to logs) and strangely still having this issue
Same here:
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000018
Crashed: com.apple.main-thread
0 appname 0x19c780 std::__1::__function::__func<reanimated::MutableValue::set(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&, facebook::jsi::Value const&)::$_2, std::__1::allocator<reanimated::MutableValue::set(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&, facebook::jsi::Value const&)::$_2>, void ()>::operator()() + 580 (shared_ptr.h:580)
1 appname 0x1c1894 reanimated::Scheduler::triggerUI() + 463 (function.h:463)
2 libdispatch.dylib 0x24b4 _dispatch_call_block_and_release + 32
3 libdispatch.dylib 0x3fdc _dispatch_client_callout + 20
4 libdispatch.dylib 0x127f4 _dispatch_main_queue_drain + 928
5 libdispatch.dylib 0x12444 _dispatch_main_queue_callback_4CF + 44
6 CoreFoundation 0x9a6f8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
7 CoreFoundation 0x7c058 __CFRunLoopRun + 2036
8 CoreFoundation 0x80ed4 CFRunLoopRunSpecific + 612
9 GraphicsServices 0x1368 GSEventRunModal + 164
10 UIKitCore 0x3a23d0 -[UIApplication _run] + 888
11 UIKitCore 0x3a2034 UIApplicationMain + 340
12 appname 0x4ff0 main + 7 (main.m:7)
13 ??? 0x1b2464960 (Falta)
I also attached the issue originaly opened on react-native-screens, got many crash from a while when putting the app in background:

I do not used custom animation actually, might be a third party library which is calling the buggy part...
Hi, any update on this ?
I also attached the issue originaly opened on react-native-screens, got many crash from a while when putting the app in background
Same here, we're seeing this issue after the app is put in the background. Don't really know how it's possible but sentry shows a lot of "going to background" logs in a row, without any "going active".
I think we gotta wait : https://github.com/software-mansion/react-native-reanimated/issues/3917
@TwistedMinda in that other thread people said upgrading to reanimated 3 fixes the issue, are you thinking that might do the same here? A stable 3 was released last month so it should be doable.
@jayfeldman12 I think successfully upgrading to reanimated 3 is gonna fix a lot of bug including this one yes, but I still can't confirm this as I'm stuck by another library currently
Hi, i'm on v3 of reanimated and get that issue a lot still, switch to expo-router last week and since then got 1XX crahes and that lead me to here. Only iOS 16 like everyone so not sure v3 would fix this unfortunately :/
After successfully migrating to reanimated v3 and react-native 0.71.3 all reanimated-related errors on Sentry are gone for me, an awesome step up
Can anyone else confirm the migration to v3 is viable solution? If so, what react-native version are you running? We are currently on 0.67.5 (latest version without new architecture) and reanimated 2.4.0.
We experience problems only on iOS, only in production and we struggle to reproduce it regularly as well. We are currently having two options. Get rid of reanimated completely or migrate it, but migrate whole project to latest RN version (and all libraries) is not an option.
@maXXCZ1 Reanimated 3.3.0 is the most stable version ever so I'd recommend upgrading. Let me know if you encounter any problems, we're happy to help.
I think I may have just gotten this error in prod with RNScreens 3.22 and Reanimated 3.5.4 (RN 0.72.5):
Does this error seem like it came from Reanimated?
@nandorojo "Attempted to dereference garbage pointer" looks familiar but the stack trace doesn't so can't say for sure. Could you send me over the whole stack trace?
@zhou0506 No, there's no "reanimated" or "screens" anywhere in the stack trace.
Hello, any update on this ?
@jamogon On what exactly?