LtbLightning / bdk-rn

Bitcoin Development Kit - React Native Module
MIT License
50 stars 15 forks source link

[iOS] Crashes on init for some devices #41

Closed Czino closed 1 year ago

Czino commented 1 year ago

This may happen to just 0.5% of iPhone users and only for around the first 10 startups, after that it appears to be working.

Specifically I can see it happening for these

Crashed: com.facebook.react.JavaScript

EXC_BREAKPOINT 0x00000001d0549d7c
Crashed: com.facebook.react.JavaScript
0   libswiftCore.dylib             0x37d7c _assertionFailure(_:_:file:line:flags:) + 312
1   libswiftCore.dylib             0xadeb0 Dictionary.init<A>(_:uniquingKeysWith:) + 646
2                     0x3b7898 BdkFunctions.init() + 27 (BdkFunctions.swift:27)

Not 100% sure but the issue might be resolved with https://github.com/LtbLightning/bdk-rn/pull/36

Czino commented 1 year ago

We will release the big FFI update onto mainnet on June 21st. The update will be rolled out to around 2000 iOS devices.

I will observe it for 1-2 weeks and report back

Czino commented 1 year ago

Found new crash reports pointing to the same issue, here's a more comprehensive log:

Crashed: com.facebook.react.JavaScript
0  libswiftCore.dylib             0x37310 _assertionFailure(_:_:file:line:flags:) + 264
1  libswiftCore.dylib             0xa3fd4 Dictionary.init<A>(_:uniquingKeysWith:) + 490
2  Peach Bitcoin                  0x445d88 BdkRnModule.init() + 46 (BdkRnModule.swift:46)
3  Peach Bitcoin                  0x445ddc @objc BdkRnModule.init() + 277248 (<compiler-generated>:277248)
4  Peach Bitcoin                  0x33114c __115-[RCTModuleData initWithModuleClass:bridge:moduleRegistry:viewRegistry_DEPRECATED:bundleManager:callableJSModules:]_block_invoke + 117 (RCTModuleData.mm:117)
5  Peach Bitcoin                  0x3315b4 -[RCTModuleData setUpInstanceAndBridge:] + 191 (RCTModuleData.mm:191)
6  Peach Bitcoin                  0x3320b4 -[RCTModuleData instance] + 413 (RCTModuleData.mm:413)
7  Peach Bitcoin                  0x3323c0 -[RCTModuleData methodQueue] + 497 (RCTModuleData.mm:497)
8  Peach Bitcoin                  0x3370d4 facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int) + 88 (RCTNativeModule.mm:88)
9  Peach Bitcoin                  0x3c58ac facebook::react::JsToNativeBridge::callNativeModules(facebook::react::JSExecutor&, folly::dynamic&&, bool) + 171 (wrap_iter.h:171)
10 Peach Bitcoin                  0x424f90 facebook::react::JSIExecutor::callNativeModules(facebook::jsi::Value const&, bool) + 365 (dynamic-inl.h:365)
11 Peach Bitcoin                  0x4246b0 facebook::react::JSIExecutor::callFunction(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, folly::dynamic const&) + 268 (JSIExecutor.cpp:268)
12 Peach Bitcoin                  0x3c6b80 std::__1::__function::__func<facebook::react::NativeToJsBridge::runOnExecutorQueue(std::__1::function<void (facebook::react::JSExecutor*)>)::$_8, std::__1::allocator<facebook::react::NativeToJsBridge::runOnExecutorQueue(std::__1::function<void (facebook::react::JSExecutor*)>)::$_8>, void ()>::operator()() + 352 (function.h:352)
13 Peach Bitcoin                  0x322204 facebook::react::tryAndReturnError(std::__1::function<void ()> const&) + 505 (function.h:505)
14 Peach Bitcoin                  0x32dfec facebook::react::RCTMessageThread::tryFunc(std::__1::function<void ()> const&) + 69 (RCTMessageThread.mm:69)
15 Peach Bitcoin                  0x32dda0 ___ZN8facebook5react16RCTMessageThread8runAsyncENSt3__18functionIFvvEEE_block_invoke + 46 (RCTMessageThread.mm:46)
16 CoreFoundation                 0x436e0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28
17 CoreFoundation                 0xaa210 __CFRunLoopDoBlocks + 364
18 CoreFoundation                 0x7a0c4 __CFRunLoopRun + 812
19 CoreFoundation                 0x7f3ec CFRunLoopRunSpecific + 612
20 Peach Bitcoin                  0x3183dc +[RCTCxxBridge runRunLoop] + 336 (RCTCxxBridge.mm:336)
21 Foundation                     0x5b544 __NSThread__start__ + 716
22 libsystem_pthread.dylib        0x16b8 _pthread_start + 148
23 libsystem_pthread.dylib        0xb88 thread_start + 8
BitcoinZavior commented 1 year ago

This may happen to just 0.5% of iPhone users and only for around the first 10 startups, after that it appears to be working.

Specifically I can see it happening for these

  • iOS 16.3.1 - iPhone 12 Pro Max
  • iOS 15.5.0 - iPhone 13 Mini

Thanks for the details. Does this info still hold true? How was this information gathered or verified?

Czino commented 1 year ago

We gather crash reports via crashlytics.

Looking back at the last 90 days, we had 50 unique devices reporting this crash

Here are more samples of affected versions devices:

BitcoinZavior commented 1 year ago

That covers a lot of phone models, so not related to the phones I think. I will investigate. This happened on one of my test phones as well so I can replicate it.

BitcoinZavior commented 1 year ago

@Czino https://github.com/LtbLightning/bdk-rn/pull/54 should address the crash issue as well

Czino commented 1 year ago

android and iOS are building and app is running

Cannot yet confirm that crashes will be resolved as I have no way of reproducing them, but am hopeful. Will report back when we deploy the next release and keep observing it 🙏