Skip to content
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

[Bug] EXC_BREAKPOINT crash after installLibrary on iOS 12.* devices #141

Closed
haikov opened this issue Jul 16, 2021 · 16 comments
Closed

[Bug] EXC_BREAKPOINT crash after installLibrary on iOS 12.* devices #141

haikov opened this issue Jul 16, 2021 · 16 comments

Comments

@haikov
Copy link

haikov commented Jul 16, 2021

Describe the bug

Hey!

We see quite a lot of EXC_BREAKPOINT crashes in Production, mostly coming from old iOS devices (the problem is almost unique to iPhone 6, 6 Plus and 7, according to the bug-reporting tool). And it only happens on iOS 12.*. Works totally fine on any other type of device / OS.

Stacktrace below:

Exception Type:     EXC_BREAKPOINT 


EXC_BREAKPOINT: 

0  AppName facebook::jsi::WithRuntimeDecorator<facebook::react::(anonymous namespace)::ReentrancyCheck, facebook::jsi::Runtime, facebook::jsi::Runtime>::Around::Around(facebook::react::(anonymous namespace)::ReentrancyCheck&) (HermesExecutorFactory.cpp:123:7)
1  AppName facebook::jsi::WithRuntimeDecorator<facebook::react::(anonymous namespace)::ReentrancyCheck, facebook::jsi::Runtime, facebook::jsi::Runtime>::createPropNameIDFromAscii(char const*, unsigned long) (decorator.h:529:12)
2  AppName install(facebook::jsi::Runtime&) (jsi.h:365:20)
3  AppName -[MMKVNative installLibrary] (MMKVNative.mm:77:5)
4  libdispatch.dylib      __dispatch_client_callout
5  libdispatch.dylib      __dispatch_continuation_pop$VARIANT$mp
6  libdispatch.dylib      __dispatch_source_invoke$VARIANT$mp
7  libdispatch.dylib      __dispatch_main_queue_callback_4CF$VARIANT$mp
8  CoreFoundation         ___CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
9  CoreFoundation         ___CFRunLoopRun
10 CoreFoundation         _CFRunLoopRunSpecific
11 Foundation             -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
12 Foundation             -[NSRunLoop(NSRunLoop) runUntilDate:]

To Reproduce
Steps to reproduce the behavior:

  1. Crash happens on application start with the library installed.

Platform Information:

  • OS: iOS, 12.*
  • React Native Version 0.64.*
  • Library Version 0.5.6

Additional context

We're also using reanimated2, which is another JSI-library and doesn't have the same problem. Which makes me think that something might be wrong during installLibrary process.

@ammarahm-ed
Copy link
Owner

ammarahm-ed commented Jul 16, 2021

Describe the bug

Hey!

We see quite a lot of EXC_BREAKPOINT crashes in Production, mostly coming from old iOS devices (the problem is almost unique to iPhone 6, 6 Plus and 7, according to the bug-reporting tool). And it only happens on iOS 12.*. Works totally fine on any other type of device / OS.

Stacktrace below:

Exception Type:     EXC_BREAKPOINT 


EXC_BREAKPOINT: 

0  AppName facebook::jsi::WithRuntimeDecorator<facebook::react::(anonymous namespace)::ReentrancyCheck, facebook::jsi::Runtime, facebook::jsi::Runtime>::Around::Around(facebook::react::(anonymous namespace)::ReentrancyCheck&) (HermesExecutorFactory.cpp:123:7)
1  AppName facebook::jsi::WithRuntimeDecorator<facebook::react::(anonymous namespace)::ReentrancyCheck, facebook::jsi::Runtime, facebook::jsi::Runtime>::createPropNameIDFromAscii(char const*, unsigned long) (decorator.h:529:12)
2  AppName install(facebook::jsi::Runtime&) (jsi.h:365:20)
3  AppName -[MMKVNative installLibrary] (MMKVNative.mm:77:5)
4  libdispatch.dylib      __dispatch_client_callout
5  libdispatch.dylib      __dispatch_continuation_pop$VARIANT$mp
6  libdispatch.dylib      __dispatch_source_invoke$VARIANT$mp
7  libdispatch.dylib      __dispatch_main_queue_callback_4CF$VARIANT$mp
8  CoreFoundation         ___CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
9  CoreFoundation         ___CFRunLoopRun
10 CoreFoundation         _CFRunLoopRunSpecific
11 Foundation             -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
12 Foundation             -[NSRunLoop(NSRunLoop) runUntilDate:]

To Reproduce
Steps to reproduce the behavior:

  1. Crash happens on application start with the library installed.

Platform Information:

  • OS: iOS, 12.*
  • React Native Version 0.64.*
  • Library Version 0.5.6

Additional context

We're also using reanimated2, which is another JSI-library and doesn't have the same problem. Which makes me think that something might be wrong during installLibrary process.

Have you tried to reproduce the bug in debug mode on 12.x version of iOS in the Simulator or Device? Does it happen in debug on iOS 12.X or does it only happen in production?

@haikov
Copy link
Author

haikov commented Jul 16, 2021

Have you tried to reproduce the bug in debug mode on 12.x version of iOS in the Simulator or Device?

I was unable to reproduce it in debug or in release mode in simulator. After further investigation, it looks like we can limit iOS version to only 12.5.*, as other 12.* are not affected. For whatever reason, there's no iOS 12.5 simulator available in latest XCode, but on 12.4 everything works correct.

@ammarahm-ed
Copy link
Owner

ammarahm-ed commented Jul 16, 2021

Well after some investigation, I think the error is caused because accessing the runtime from the wrong thread. However I don't understand why it is happening only on a specific version of iOS and not other versions.

Because the error is happening inside the dispatch block, maybe we can remove it and see if that would help.

- (void)installLibrary {

Fork the master branch and try removing the following code

   if (!cxxBridge.runtime) {
        
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.001 * NSEC_PER_SEC),
                       dispatch_get_main_queue(), ^{
            /**
             When refreshing the app while debugging, the setBridge
             method is called too soon. The runtime is not ready yet
             quite often. We need to install library as soon as runtime
             becomes available.
             */
            [self installLibrary];
        });
        return;
    }
    

replace it with following:

 if (!cxxBridge.runtime) { 
        return;
    }

Then use it instead of the released version on npm.

If you have any people who can test, that would be great otherwise the only option is to either download ios 12.5 on an iphone and downgrade or release to production again to see if the error goes away/some new error comes up

@ammarahm-ed
Copy link
Owner

Also I think the error will only come in release builds. Not in debug mode so make sure if you are testing on other ios 12.x versions, it's not in debug.

@haikov
Copy link
Author

haikov commented Jul 16, 2021

Thanks, will try to apply a patch with these changes and do couple of tests to see if this would help. I will get back here with an update as soon as I have anything.

@ammarahm-ed
Copy link
Owner

Closing due to inactivity.

@dancixx
Copy link

dancixx commented Nov 21, 2021

Hi, I got the same error today on 15.1.0 and 15.0.2.

Crashed: com.apple.main-thread
EXC_BREAKPOINT 0x00000001046c2ca8

@DanijelBojcic
Copy link

DanijelBojcic commented Dec 17, 2021

Also happens on iOS 15.2.0 in production build.
MMKV version : 0.6.6

Here is the stacktrace:

Crashed: com.apple.main-thread
0  pierre                         0x2e4378 facebook::jsi::WithRuntimeDecorator<facebook::react::(anonymous namespace)::ReentrancyCheck, facebook::jsi::Runtime, facebook::jsi::Runtime>::Around::Around(facebook::react::(anonymous namespace)::ReentrancyCheck&) + 123 (HermesExecutorFactory.cpp:123)
1  pierre                         0x2e1cac facebook::jsi::WithRuntimeDecorator<facebook::react::(anonymous namespace)::ReentrancyCheck, facebook::jsi::Runtime, facebook::jsi::Runtime>::createPropNameIDFromAscii(char const*, unsigned long) + 170 (decorator.h:170)
2  pierre                         0x37098c install(facebook::jsi::Runtime&) + 1672 (functional:1672)
3  pierre                         0x370850 -[MMKVNative installLibrary] + 88 (MMKVNative.mm:88)
4  libdispatch.dylib              0x3bac _dispatch_client_callout + 20
5  libdispatch.dylib              0x7080 _dispatch_continuation_pop + 504
6  libdispatch.dylib              0x1a1a4 _dispatch_source_invoke + 1356
7  libdispatch.dylib              0x12000 _dispatch_main_queue_callback_4CF + 772
8  CoreFoundation                 0xc5f00 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
9  CoreFoundation                 0x838c0 __CFRunLoopRun + 2540
10 CoreFoundation                 0x82734 CFRunLoopRunSpecific + 600
11 HIToolbox                      0x32f68 RunCurrentEventLoopInMode + 292
12 HIToolbox                      0x32cdc ReceiveNextEventCommon + 552
13 HIToolbox                      0x32a9c _BlockUntilNextEventMatchingListInModeWithFilter + 72
14 AppKit                         0x41ce0 _DPSNextEvent + 844
15 AppKit                         0x40584 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1332
16 AppKit                         0x325a4 -[NSApplication run] + 596
17 AppKit                         0x3c78 NSApplicationMain + 1064
18 AppKit                         0x2da084 _NSApplicationMainWithInfoDictionary + 22
19 UIKitMacHelper                 0x49ac UINSApplicationMain + 1280
20 UIKitCore                      0x3b28 UIApplicationMain + 164
21 pierre                         0x4e6c main + 14 (main.m:14)
22 ???                            0x1077ad0f4 (Missing)

@abejfehr
Copy link

abejfehr commented Jan 19, 2022

This started happening for me after upgrading react-native to 0.66

@haikov did the patch work?

@ammarahm-ed
Copy link
Owner

@abejfehr How many occurrences are you seeing?

@abejfehr
Copy link

abejfehr commented Jan 26, 2022

@ammarahm-ed there are thousands of occurrences in this case, it's not a rare error

@ammarahm-ed
Copy link
Owner

@abejfehr I am working on a possible fix. Will update soon in #195

@ammarahm-ed ammarahm-ed reopened this Jan 26, 2022
@ammarahm-ed
Copy link
Owner

@abejfehr try the new fix in #195

@ammarahm-ed
Copy link
Owner

Released v0.6.11

@abejfehr
Copy link

abejfehr commented Feb 9, 2022

Even with version 0.6.11, iOS 12 devices were still crashing 😞

Fortunately it wasn't due to MMKV at all 🎉

It looks like this issue was the cause of those crashes.

Updating to version 0.6.11 of this library is key for that EXC_BREAKPOINT issue, but I'd advise anyone in this thread using XCode 13 to look into the missing LinkPresentation.framework issue as well in case that's causing crashes as well.

Thank you so much for the fix @ammarahm-ed!

@ammarahm-ed
Copy link
Owner

Even with version 0.6.11, iOS 12 devices were still crashing 😞

Fortunately it wasn't due to MMKV at all 🎉

It looks like this issue was the cause of those crashes.

Updating to version 0.6.11 of this library is key for that EXC_BREAKPOINT issue, but I'd advise anyone in this thread using XCode 13 to look into the missing LinkPresentation.framework issue as well in case that's causing crashes as well.

Thank you so much for the fix @ammarahm-ed!

I am glad you were able to figure this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants