question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

crash in bridge code with some native module.

See original GitHub issue

🐛 Bug Report

Crash in bridge code in Release build only. Works in Debug

void RCTNativeModule::invoke(unsigned int methodId, folly::dynamic &&params, int callId) {
  // capture by weak pointer so that we can safely use these variables in a callback
  __weak RCTBridge *weakBridge = m_bridge;
  __weak RCTModuleData *weakModuleData = m_moduleData;
  // The BatchedBridge version of this buckets all the callbacks by thread, and
  // queues one block on each.  This is much simpler; we'll see how it goes and
  // iterate.
  dispatch_block_t block = [weakBridge, weakModuleData, methodId, params=std::move(params), callId] {
    #ifdef WITH_FBSYSTRACE
    if (callId != -1) {
      fbsystrace_end_async_flow(TRACE_TAG_REACT_APPS, "native", callId);
    }
    #endif
    invokeInner(weakBridge, weakModuleData, methodId, std::move(params));
  };

  if (m_bridge.valid) {
    dispatch_queue_t queue = m_moduleData.methodQueue;
    if (queue == RCTJSThread) {
      block();
    } else if (queue) {
      dispatch_async(queue, block); <----- com.facebook.react.JavaScript (8): EXC_BAD_ACCESS (code=2, address=0x1c20a79b8)
    }
  } else {
    RCTLogWarn(@"Attempted to invoke `%u` (method ID) on `%@` (NativeModule name) with an invalid bridge.",
               methodId, m_moduleData.name);
  }
}

com.facebook.react.JavaScript (8) /!\ This thread has caused the crash

To Reproduce

I’m using several native modules so, deciding which one is faulty is complicated for me. I’m using Cocoapods, following is my pod file:

platform :ios, '9.0'
	
use_frameworks!
	
target 'MyTarget' do
    pod 'yoga', path: '../node_modules/react-native/ReactCommon/yoga/'
    pod 'React', path: '../node_modules/react-native/', :subspecs => [
    'Core',
    'ART',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTLinkingIOS',
    'RCTGeolocation',
    'RCTImage',
    'RCTNetwork',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'DevSupport',
    'CxxBridge',
    ]
    
    pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
    pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
    pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
    
    pod 'RNCharts', :path => '../node_modules/react-native-charts-wrapper'
    pod 'RNSVG', :path => '../node_modules/react-native-svg'

end
	
swift4 = ['Charts']

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if swift4.include?(target.name)
        config.build_settings['SWIFT_VERSION'] = '4.1'
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= []
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'DEBUG=1'
      end
    end
  end
end

An the result of the install:

Oliviers-iMac:ios omatrot$ pod install
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
Fetching podspec for `Folly` from `../node_modules/react-native/third-party-podspecs/Folly.podspec`
Fetching podspec for `RNCharts` from `../node_modules/react-native-charts-wrapper`
Fetching podspec for `RNSVG` from `../node_modules/react-native-svg`
Fetching podspec for `React` from `../node_modules/react-native/`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
Fetching podspec for `yoga` from `../node_modules/react-native/ReactCommon/yoga/`
Downloading dependencies
Installing Charts (3.1.1)
Installing DoubleConversion (1.1.6)
Installing Folly (2016.10.31.00)
Using RNCharts (0.5.0)
Using RNSVG (9.2.4)
Using React (0.57.4)
Installing SwiftyJSON (4.1.0)
Installing boost-for-react-native (1.63.0)
Installing glog (0.3.5)
Using yoga (0.57.4.React)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `MyHeartSigns.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There are 19 dependencies from the Podfile and 10 total pods installed.

Expected Behavior

No crash at all.

Code Example

Environment

React Native Environment Info: System: OS: macOS 10.14.3 CPU: (4) x64 Intel® Core™ i5-5350U CPU @ 1.80GHz Memory: 42.34 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 8.11.2 - /usr/local/bin/node Yarn: 1.13.0 - /usr/local/bin/yarn npm: 6.8.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1 Android SDK: API Levels: 14, 23, 24, 25, 26, 27, 28 Build Tools: 23.0.1, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.2, 27.0.3, 28.0.0, 28.0.2, 28.0.3 IDEs: Android Studio: 3.3 AI-182.5107.16.33.5314842 Xcode: 10.1/10B61 - /usr/bin/xcodebuild npmPackages: react: ^16.8.3 => 16.8.4 react-native: ^0.59.0 => 0.59.0 npmGlobalPackages: create-react-native-app: 1.0.0 react-native-cli: 2.0.1 react-native-git-upgrade: 0.2.7 react-native-rename: 2.2.2 react-native: 0.59.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
zim-leecommented, Jul 12, 2019

@omatrot did you fix it? I have the same issue. only crash in Release Mode.

1reaction
omatrotcommented, Aug 14, 2019

Is solved this problem (and many others) by manually installing native modules and not relying on CocoaPods anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does my Android react native app crash instantly when I ...
Why does my Android react native app crash instantly when I try to bridge device listening modules from Java · Have you tried...
Read more >
React Native (Bridge) - Countly
If you have C++ libraries in your React Native Android app, the React Native Bridge SDK allows you to record possible crashes in...
Read more >
Handling our First Live Incident as a Startup | by Gery Nugraha
Our next hypothesis is that the app will only crash for a certain ... and this native code will then be abstracted by...
Read more >
Get Started with React Native - Visual Studio App Center
The App Center SDK uses a modular architecture so you can use any or all of ... a single framework for the required...
Read more >
North Carolina - Greensboro-nc.gov
N Native. American. H Hispanic. A Asian. O Other*. U Unknown. (22) Person ... A motor vehicle crash is any event that results...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found