react-native-reanimated icon indicating copy to clipboard operation
react-native-reanimated copied to clipboard

[iOS] Crash in MutableValue::set

Open DanijelBojcic opened this issue 3 years ago • 27 comments

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

DanijelBojcic avatar Oct 01 '22 09:10 DanijelBojcic

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.

github-actions[bot] avatar Oct 01 '22 09:10 github-actions[bot]

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?

github-actions[bot] avatar Oct 01 '22 09:10 github-actions[bot]

Hey @DanijelBojcic, thanks for opening this issue.

Can you please prepare a minimal viable reproduction for this bug?

tomekzaw avatar Oct 02 '22 10:10 tomekzaw

We're getting the same issue, randomly on release mode only, this is the crash from XCode:

Capture d’écran 2022-10-10 à 14 42 20

Seems to be happening when unmounting a component running an animation.

Aximem avatar Oct 10 '22 12:10 Aximem

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

DanijelBojcic avatar Oct 11 '22 08:10 DanijelBojcic

I have no idea this is related to this. But it seems to this is not only iOS16 issue image

mym0404 avatar Oct 14 '22 01:10 mym0404

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.

image

jinliming2 avatar Oct 23 '22 17:10 jinliming2

we are seeing this issue as well iOS 16 only React Native version 68.5

jmorey28 avatar Dec 12 '22 16:12 jmorey28

Any Update on this?

ParthChugh avatar Jan 06 '23 06:01 ParthChugh

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.

terribleben avatar Jan 10 '23 20:01 terribleben

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

levepic avatar Jan 15 '23 16:01 levepic

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)

mtebele avatar Feb 22 '23 14:02 mtebele

I also attached the issue originaly opened on react-native-screens, got many crash from a while when putting the app in background: image

I do not used custom animation actually, might be a third party library which is calling the buggy part...

Dallas62 avatar Feb 24 '23 07:02 Dallas62

Hi, any update on this ?

thibaultfischer avatar Mar 07 '23 08:03 thibaultfischer

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 avatar Mar 21 '23 10:03 TwistedMinda

@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 avatar Mar 31 '23 14:03 jayfeldman12

@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

TwistedMinda avatar Apr 01 '23 18:04 TwistedMinda

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 :/

Screenshot 2023-05-29 at 10 50 09

Screenshot 2023-05-30 at 11 01 57

wcastand avatar May 29 '23 08:05 wcastand

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

TwistedMinda avatar Jun 02 '23 01:06 TwistedMinda

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 avatar Jun 29 '23 08:06 maXXCZ1

@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.

tomekzaw avatar Jun 29 '23 08:06 tomekzaw

I think I may have just gotten this error in prod with RNScreens 3.22 and Reanimated 3.5.4 (RN 0.72.5):

image

Does this error seem like it came from Reanimated?

nandorojo avatar Oct 30 '23 22:10 nandorojo

@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?

tomekzaw avatar Oct 31 '23 08:10 tomekzaw

@zhou0506 No, there's no "reanimated" or "screens" anywhere in the stack trace.

tomekzaw avatar Dec 14 '23 08:12 tomekzaw

Hello, any update on this ?

jamogon avatar Feb 14 '24 08:02 jamogon

@jamogon On what exactly?

tomekzaw avatar Feb 14 '24 11:02 tomekzaw