facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.46k stars 24.25k forks source link

App crash when enabling bridgeless on iOS #46686

Open sherryxpq opened 2 days ago

sherryxpq commented 2 days ago

Description

My app can work in the legacy architecture, and it can also work when I enable new architecture but disable bridgeless layer.

image

But once I enable bridgeless layer, the app will crash right after it loads the UI, and it will always throws a bad access exception at the same method, like the screenshot shows.

image image

Is there any other modifications I need to do to use bridgeless layer in new architecture?

Steps to reproduce

  1. Run @zoom/react-native-videosdk to install the dependency
  2. Call functions
      <ZoomVideoSdkProvider
        config={{
          appGroupId: 'group.test.sdk',
          domain: 'zoom.us',
          enableLog: true,
        }}>
        <Navigation />
      </ZoomVideoSdkProvider>
  3. Build and run the app in new architecture with bridgeless layer on.
  4. The app will crash after loading.

React Native Version

0.75.3

Affected Platforms

Runtime - iOS

Areas

JSI - Javascript Interface, Bridgeless - The New Initialization Flow

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: macOS 14.6.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 344.33 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.0.0
    path: ~/.nvm/versions/node/v20.0.0/bin/node
  Yarn:
    version: 1.22.22
    path: ~/Documents/work/rntestnewarch/node_modules/.bin/yarn
  npm:
    version: 9.6.4
    path: ~/.nvm/versions/node/v20.0.0/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/QingPeng/.gem/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK:
    API Levels:
      - "28"
      - "29"
      - "30"
      - "31"
      - "32"
      - "33"
      - "34"
    Build Tools:
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 32.0.0
      - 33.0.0
      - 33.0.1
      - 34.0.0
    System Images:
      - android-30 | Google Play ARM 64 v8a
      - android-31 | ARM 64 v8a
      - android-31 | Google APIs ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
      - android-33 | Google Play ARM 64 v8a
      - android-34 | Google Play ARM 64 v8a
    Android NDK: 22.1.7171670
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11330709
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.3
    wanted: 0.75.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

### Stacktrace or Logs

```text
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Incident Identifier: D6A010C3-AFAB-4248-889E-BE34324790E0
CrashReporter Key:   32FAE1E6-3700-C64C-4955-DC59F8BB1B1F
Hardware Model:      MacBookPro18,1
Process:             rntestnewarch [57977]
Path:                /Users/USER/Library/Developer/CoreSimulator/Devices/559DC24A-EAFB-4443-BFDD-7C798B5BA3A6/data/Containers/Bundle/Application/5FFB1F8D-7A69-43A5-9D53-9C4E20F62960/rntestnewarch.app/rntestnewarch
Identifier:          org.reactjs.native.example.rntestnewarch
Version:             1.0 (1)
Code Type:           X86-64 (Native)
Role:                Foreground
Parent Process:      launchd_sim [57485]
Coalition:           com.apple.CoreSimulator.SimDevice.559DC24A-EAFB-4443-BFDD-7C798B5BA3A6 [11589]
Responsible Process: SimulatorTrampoline [2838]

Date/Time:           2024-09-27 00:27:33.2773 -0700
Launch Time:         2024-09-27 00:27:21.7327 -0700
OS Version:          macOS 14.6.1 (23G93)
Release Type:        User
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Codes: 0x0000000000000001, 0x0000000000000000
VM Region Info: 0 is not in any region.  Bytes before following region: 4375568384
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                      104cde000-105a5d000    [ 13.5M] r-x/r-x SM=COW  /Users/USER/Library/Developer/CoreSimulator/Devices/559DC24A-EAFB-4443-BFDD-7C798B5BA3A6/data/Containers/Bundle/Application/5FFB1F8D-7A69-43A5-9D53-9C4E20F62960/rntestnewarch.app/rntestnewarch
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [57977]

Triggered by Thread:  8

Kernel Triage:
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter
VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter

Thread 0::  Dispatch queue: com.apple.main-thread
0   ???                                    0x10815fa78 ???
1   <translation info unavailable>         0x10824088c ???
2   libsystem_kernel.dylib                 0x116d88878 mach_msg2_internal + 84
3   libsystem_kernel.dylib                 0x116d81178 mach_msg_overwrite + 653
4   libsystem_kernel.dylib                 0x116d7a37d mach_msg + 19
5   CoreFoundation                         0x11320e8a3 __CFRunLoopServiceMachPort + 143
6   CoreFoundation                         0x11320902b __CFRunLoopRun + 1371
7   CoreFoundation                         0x1132086ed CFRunLoopRunSpecific + 557
8   GraphicsServices                       0x12511208f GSEventRunModal + 137
9   UIKitCore                              0x136d636ee -[UIApplication _run] + 972
10  UIKitCore                              0x136d6816e UIApplicationMain + 123
11  rntestnewarch                          0x104ce0900 main + 96 (main.m:8)
12  dyld_sim                               0x110a023e0 start_sim + 10
13  dyld                                   0x208232345 start + 1909

Thread 1:: com.apple.rosetta.exceptionserver
0   ???                                 0x7ff7ffd77414 ???

Thread 2:
0   ???                                 0x7ff7ffd9594c ???

Thread 3:
0   ???                                 0x7ff7ffd9594c ???

Thread 4:: com.apple.uikit.eventfetch-thread
0   ???                                    0x10815fa78 ???
1   <translation info unavailable>         0x10824088c ???
2   libsystem_kernel.dylib                 0x116d88878 mach_msg2_internal + 84
3   libsystem_kernel.dylib                 0x116d81178 mach_msg_overwrite + 653
4   libsystem_kernel.dylib                 0x116d7a37d mach_msg + 19
5   CoreFoundation                         0x11320e8a3 __CFRunLoopServiceMachPort + 143
6   CoreFoundation                         0x11320902b __CFRunLoopRun + 1371
7   CoreFoundation                         0x1132086ed CFRunLoopRunSpecific + 557
8   Foundation                             0x118ac6c9a -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 213
9   Foundation                             0x118ac6f18 -[NSRunLoop(NSRunLoop) runUntilDate:] + 72
10  UIKitCore                              0x136e407aa -[UIEventFetcher threadMain] + 518
11  Foundation                             0x118af14d5 __NSThread__start__ + 1024
12  libsystem_pthread.dylib                0x116ef418b _pthread_start + 99
13  libsystem_pthread.dylib                0x116eefae3 thread_start + 15

Thread 5:
0   ???                                 0x7ff7ffd9594c ???

Thread 6:
0   ???                                 0x7ff7ffd9594c ???

Thread 7:
0   ???                                 0x7ff7ffd9594c ???

Thread 8 Crashed:: com.facebook.react.runtime.JavaScript
0   <translation info unavailable>         0x10823ccf8 ???
1   rntestnewarch                          0x104d1f9d5 std::__1::__constexpr_strlen[abi:ue170006](char const*) + 21 (constexpr_c_functions.h:49)
2   rntestnewarch                          0x104d1f915 std::__1::char_traits<char>::length[abi:ue170006](char const*) + 21 (char_traits.h:222)
3   rntestnewarch                          0x104d1f8b6 std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::basic_string[abi:ue170006]<0>(char const*) + 54 (string:940)
4   rntestnewarch                          0x104d1e85d std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::basic_string[abi:ue170006]<0>(char const*) + 29 (string:938)
5   rntestnewarch                          0x1053eda19 facebook::react::(anonymous namespace)::parseExportedMethods(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, objc_class*) + 489 (RCTInteropTurboModule.mm:126)
6   rntestnewarch                          0x1053ecf0b facebook::react::ObjCInteropTurboModule::ObjCInteropTurboModule(facebook::react::ObjCTurboModule::InitParams const&) + 203 (RCTInteropTurboModule.mm:188)
7   rntestnewarch                          0x1053eed3d facebook::react::ObjCInteropTurboModule::ObjCInteropTurboModule(facebook::react::ObjCTurboModule::InitParams const&) + 29 (RCTInteropTurboModule.mm:187)
8   rntestnewarch                          0x105428219 facebook::react::ObjCInteropTurboModule* std::__1::construct_at[abi:ue170006]<facebook::react::ObjCInteropTurboModule, facebook::react::ObjCTurboModule::InitParams&, facebook::react::ObjCInteropTurboModule*>(facebook::react::ObjCInteropTurboModule*, facebook::react::ObjCTurboModule::InitParams&) + 41 (construct_at.h:41)
9   rntestnewarch                          0x105428051 void std::__1::allocator_traits<std::__1::allocator<facebook::react::ObjCInteropTurboModule>>::construct[abi:ue170006]<facebook::react::ObjCInteropTurboModule, facebook::react::ObjCTurboModule::InitParams&, void, void>(std::__1::allocator<facebook::react::ObjCInteropTurboModule>&, facebook::react::ObjCInteropTurboModule*, facebook::react::ObjCTurboModule::InitParams&) + 33 (allocator_traits.h:304)
10  rntestnewarch                          0x105427f9b std::__1::__shared_ptr_emplace<facebook::react::ObjCInteropTurboModule, std::__1::allocator<facebook::react::ObjCInteropTurboModule>>::__shared_ptr_emplace[abi:ue170006]<facebook::react::ObjCTurboModule::InitParams&>(std::__1::allocator<facebook::react::ObjCInteropTurboModule>, facebook::react::ObjCTurboModule::InitParams&) + 107 (shared_ptr.h:300)
11  rntestnewarch                          0x105427ced std::__1::__shared_ptr_emplace<facebook::react::ObjCInteropTurboModule, std::__1::allocator<facebook::react::ObjCInteropTurboModule>>::__shared_ptr_emplace[abi:ue170006]<facebook::react::ObjCTurboModule::InitParams&>(std::__1::allocator<facebook::react::ObjCInteropTurboModule>, facebook::react::ObjCTurboModule::InitParams&) + 29 (shared_ptr.h:292)
12  rntestnewarch                          0x105427bf6 std::__1::shared_ptr<facebook::react::ObjCInteropTurboModule> std::__1::allocate_shared[abi:ue170006]<facebook::react::ObjCInteropTurboModule, std::__1::allocator<facebook::react::ObjCInteropTurboModule>, facebook::react::ObjCTurboModule::InitParams&, void>(std::__1::allocator<facebook::react::ObjCInteropTurboModule> const&, facebook::react::ObjCTurboModule::InitParams&) + 70 (shared_ptr.h:1023)
13  rntestnewarch                          0x10541cdc5 std::__1::shared_ptr<facebook::react::ObjCInteropTurboModule> std::__1::make_shared[abi:ue170006]<facebook::react::ObjCInteropTurboModule, facebook::react::ObjCTurboModule::InitParams&, void>(facebook::react::ObjCTurboModule::InitParams&) + 53 (shared_ptr.h:1032)
14  rntestnewarch                          0x10541caf0 -[RCTTurboModuleManager provideLegacyModule:] + 1424 (RCTTurboModuleManager.mm:470)
15  rntestnewarch                          0x10542d556 -[RCTTurboModuleManager installJSBindings:]::$_1::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const + 118 (RCTTurboModuleManager.mm:959)
16  rntestnewarch                          0x10542d4c8 decltype(std::declval<-[RCTTurboModuleManager installJSBindings:]::$_1&>()(std::declval<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&>())) std::__1::__invoke[abi:ue170006]<-[RCTTurboModuleManager installJSBindings:]::$_1&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&>(-[RCTTurboModuleManager installJSBindings:]::$_1&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 40 (invoke.h:340)
17  rntestnewarch                          0x10542d468 std::__1::shared_ptr<facebook::react::TurboModule> std::__1::__invoke_void_return_wrapper<std::__1::shared_ptr<facebook::react::TurboModule>, false>::__call[abi:ue170006]<-[RCTTurboModuleManager installJSBindings:]::$_1&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&>(-[RCTTurboModuleManager installJSBindings:]::$_1&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 40 (invoke.h:407)
18  rntestnewarch                          0x10542d428 std::__1::__function::__alloc_func<-[RCTTurboModuleManager installJSBindings:]::$_1, std::__1::allocator<-[RCTTurboModuleManager installJSBindings:]::$_1>, std::__1::shared_ptr<facebook::react::TurboModule> (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)>::operator()[abi:ue170006](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 56 (function.h:193)
19  rntestnewarch                          0x10542c2cc std::__1::__function::__func<-[RCTTurboModuleManager installJSBindings:]::$_1, std::__1::allocator<-[RCTTurboModuleManager installJSBindings:]::$_1>, std::__1::shared_ptr<facebook::react::TurboModule> (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)>::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 44 (function.h:364)
20  rntestnewarch                          0x10584111d std::__1::__function::__value_func<std::__1::shared_ptr<facebook::react::TurboModule> (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)>::operator()[abi:ue170006](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const + 77 (function.h:518)
21  rntestnewarch                          0x10583dd48 std::__1::function<std::__1::shared_ptr<facebook::react::TurboModule> (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)>::operator()(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const + 40 (function.h:1169)
22  rntestnewarch                          0x10583da28 facebook::react::TurboModuleBinding::getModule(facebook::jsi::Runtime&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) const + 120 (TurboModuleBinding.cpp:137)
23  rntestnewarch                          0x105840ae9 facebook::react::BridgelessNativeModuleProxy::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&) + 217 (TurboModuleBinding.cpp:46)
24  rntestnewarch                          0x104e908d6 facebook::jsi::DecoratedHostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&) + 86 (decorator.h:70)
...

Reproducer

https://github.com/sherryxpq/rntestnewarch

Screenshots and Videos

No response

cipolleschi commented 2 days ago

@sherryxpq Thanks for trying out the New Architecture and for reporting the issue. I believe that the problem happens because the library @zoom/react-native-videosdk has not migrated to the New Architecture and we might have some gaps in the interop layer.

Also, thanks for the reproducer!

A few questions:

  1. Have you tried the reproducer with 0.76.0-rc.2? We might have solved the issue already
  2. Does it happen on Android as well or is it an iOS only issue?

I'll probably can have a look at this next week.

sherryxpq commented 1 day ago

Hi @cortinico , thanks for the quick response!

For the questions you came up with:

  1. Have you tried the reproducer with 0.76.0-rc.2? We might have solved the issue already I tried with this version, it can build successfully like in the version 0.75.3, but when the app loads, it throws a different error

    image
  2. Does it happen on Android as well or is it an iOS only issue? No, Android can work well, the crash only happens on iOS with bridgeless layer enabled.

Also, you mentioned that the library @zoom/react-native-videosdk has not migrated to the New Architecture, can you please let me know how to do the migration for the library? Much appreciated!

cipolleschi commented 17 hours ago

@sherryxpq I am @cipolleschi… @cortinico is a colleague of mine…😅

for the error on RC.2, that’s weird. We fixed that js error already. Can you try delete node_modules, yarn.lock file and rerun yarn install? I believe that there are some caching issues related to Babel.

for point 2, are you the maintainer of the library? Migrating a library is something that only the maintainers of that library can do. In theory, this should not be needed for version 0.76, but it would be required at some point in the future. We have some guides on how to do it here and here.