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 &¶ms, 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:
- Created 5 years ago
- Comments:11 (2 by maintainers)
Top GitHub Comments
@omatrot did you fix it? I have the same issue. only crash in Release Mode.
Is solved this problem (and many others) by manually installing native modules and not relying on CocoaPods anymore.