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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash in bridge code with some native module. #23564

Closed
omatrot opened this issue Feb 20, 2019 · 11 comments

Comments

@omatrot
Copy link

commented Feb 20, 2019

馃悰 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(R) Core(TM) 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

@react-native-bot

This comment has been minimized.

Copy link
Collaborator

commented Feb 20, 2019

It looks like you are using an older version of React Native. Please update to the latest release, v0.58 and verify if the issue still exists.

The "Resolution: Old Version" label will be removed automatically once you edit your original post with the results of running react-native info on a project using the latest release.

@hramos

This comment has been minimized.

Copy link
Contributor

commented Feb 20, 2019

Can you provide a minimal reproduction? I don鈥檛 see this issue reaching a resolution without one. As it happens, debugging individual crashes in any given project falls out of scope for this issue tracker.

@omatrot

This comment has been minimized.

Copy link
Author

commented Feb 21, 2019

@aleclarson

This comment has been minimized.

Copy link
Contributor

commented Feb 26, 2019

Does it crash every time in Release mode? Does your code ever invalidate the bridge explicitly?

Remove any business logic so you can share the repo.

@omatrot

This comment has been minimized.

Copy link
Author

commented Feb 26, 2019

@omatrot

This comment has been minimized.

Copy link
Author

commented Mar 2, 2019

Here is the repo for you to check the issue.
rnios23564.zip

@omatrot

This comment has been minimized.

Copy link
Author

commented Mar 13, 2019

recently upgraded the repo to 0.59.0.
Same issue.

MacBook-Air-de-Olivier:application omatrot$ react-native info
info
React Native Environment Info:
System:
OS: macOS 10.14.3
CPU: (4) x64 Intel(R) Core(TM) 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

@hramos hramos changed the title RN 0.57.4 | iOS : crash in bridge code with some native module. crash in bridge code with some native module. Mar 14, 2019

@cpojer cpojer referenced this issue Mar 19, 2019

Closed

RN Issue Triage Group 3 #24030

49 of 160 tasks complete
@bartolkaruza

This comment has been minimized.

Copy link
Collaborator

commented Mar 19, 2019

Hi @omatrot thanks for the issue report. I've downloaded your reproduction zip and I'm not finding it easy to pinpoint the issue from there. There is a large set of dependencies and library code in the project. To find the issue, I suggest you start stripping the project of dependencies and code piece by piece, until the issue stops. The last piece you removed is the one causing the issue. When you find it, you can post an issue on the repository of that library where the maintainers will be able to help you.

If the issue turns out to actually be related to RN core, feel free to post the minimal repro showing this and I'll gladly reopen the issue.

@zim-lee

This comment has been minimized.

Copy link

commented Jul 12, 2019

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

@matrpedreira

This comment has been minimized.

Copy link

commented Aug 1, 2019

I'm having the same issue also. Xcode 10.3. Swift 4.2.

"name": "albums", "version": "0.0.1", "private": true, "scripts": { "start": "yarn react-native start", "haul": "haul start" }, "dependencies": { "axios": "^0.16.2", "metro-react-native-babel-preset": "^0.55.0", "moment": "^2.24.0", "moment-timezone": "^0.5.26", "prop-types": "^15.7.2", "react": "16.8.3", "react-native": "0.59.10", "react-native-keyboard-aware-scroll-view": "^0.8.0", "react-native-masked-text": "^1.12.3" }, "devDependencies": { "@babel/core": "^7.5.4", "@babel/plugin-transform-runtime": "7.0.0", "@babel/runtime": "^7.5.4", "@haul-bundler/babel-preset-react-native": "^0.10.0", "@haul-bundler/cli": "^0.10.0", "@haul-bundler/preset-0.59": "^0.10.0", "babel-jest": "^24.8.0", "eslint-config-rallycoding": "^3.2.0", "jest": "^24.8.0", "metro-react-native-babel-preset": "^0.55.0", "react-test-renderer": "16.8.3" }, "jest": { "preset": "react-native" } }
Package.json
On debug it works and on Release it crashs in the same place if I click on anything on the screen

@omatrot

This comment has been minimized.

Copy link
Author

commented Aug 14, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can鈥檛 perform that action at this time.