facebook / react-native

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

RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks #16376

Closed antoinerousseau closed 1 year ago

antoinerousseau commented 6 years ago

I randomly get this warning at iOS app start (i.e. not always).

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

OS: macOS Sierra 10.12.6 Node: 6.10.2 Yarn: 1.0.2 npm: 5.4.2 Watchman: 4.7.0 Xcode: Xcode 9.0 Build version 9A235 Android Studio: 2.1 AI-143.2915827

Packages: (wanted => installed) react: ^16.0.0 => 16.0.0 react-native: ^0.49.3 => 0.49.3

Steps to Reproduce

  1. Start the app

    Expected Behavior

No warning

Actual Behavior

capture d ecran 2017-10-15 12 49 45

Reproducible Demo

N/A

Some packages I use

https://github.com/antoinerousseau/react-native-custom-components https://github.com/rebeccahughes/react-native-device-info https://github.com/evollu/react-native-fcm https://github.com/gwmccull/react-native-polyfill https://github.com/getsentry/react-native-sentry

almostintuitive commented 6 years ago

Same here!

eggybot commented 6 years ago

got this yellow issue for iOS

rizzomichaelg commented 6 years ago

I see this as well. Possibly related to #11196.
I believe this is what is also causing the app to crash when trying to reload; it fails with Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This method must not be called before the JS thread is created'

jozan commented 6 years ago

I'm also getting this error from time to time on iOS 11 and I've got no idea how to debug this to give more information. Stacktrace doesn't help at all in this case.

minikin commented 6 years ago

+1

mkozhukharenko commented 6 years ago

+1

antoinerousseau commented 6 years ago

Please stop adding +1s, this is generating email notifications that don't add any information. Use the "add reaction" feature instead.

dantman commented 6 years ago

Same issue. Here are the packages I use:

Given the intersection with @antoinerousseau's list, the possible locations for this bug are:

disjfa commented 6 years ago

I just added react-native-device-info, and moved from rn 0.49 to 0.50. and now i found this bug. Don't know if it's the problem, but it's when i got this.

MilkBiscuit commented 6 years ago

Same issue... So it was not my fault ?

WhoJave commented 6 years ago

Same issue... Do u have any solutions ?

SMJ93 commented 6 years ago

Same issue. The only package from the list above we use is react-native-sentry.

bullantt commented 6 years ago

Same issue here today i have started a brand new app and only package i have added "native-base": "^2.3.3", "react": "16.0.0", "react-native": "0.50.3", "react-native-fcm": "^10.0.3"

fishmwei commented 6 years ago

@rizzomichaelg +1 "react-native": "0.49.3", app crashed when first load randomly.

anybody resolved it ??

thejacobseely commented 6 years ago

@dantman I started seeing the issue immediately after installing react-native-device-info, so I highly suspect the issue is related, at least in our case, to that specific package.

The only other package I am using react-native-keychain, which I installed quite a while ago without any issues, so it seems like a good bet.

ahanriat commented 6 years ago

👀 https://github.com/rebeccahughes/react-native-device-info/issues/260

dantman commented 6 years ago

rebeccahughes/react-native-device-info#260 seems to have a message referring to RNDeviceInfo while this bug refers to RCTDevLoadingView. So there may be more than one spot triggering this warning.

mattijsf commented 6 years ago

If you would put a breakpoint on the following line:

RCTLogWarn(@"RCTBridge required dispatch_sync to load %@. This may lead to deadlocks", _moduleClass);

You can see which module/stack is responsible for loading RCTDevLoadingView in my case it was RCTCxxBridge.mm which was loading the remote bundle and reporting the download progress on RCTDevLoadingView:

... onProgress:^(RCTLoadingProgress *progressData) {
#if RCT_DEV && __has_include("RCTDevLoadingView.h")
      RCTDevLoadingView *loadingView = [weakSelf moduleForClass:[RCTDevLoadingView class]];
      [loadingView updateProgress:progressData];
#endif
    }];

Here the RCTCxxBridge is using moduleForClass which will load an instance of the module if it is not yet available. Due to the queue used for the onProgress block RCTDevLoadingView would be loaded on a non-main queue, while RCTDevLoadingView requires a main-queue setup.

I was able to workaround the warning by optimistically load RCTDevLoadingView by returning an instance from my RCTBridgeDelegate using: - (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge;

grossingdev commented 6 years ago

I was able to workaround the warning by updating AppDelegate.m

#if RCT_DEV
#import <React/RCTDevLoadingView.h>
#endif
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation
                                            moduleProvider:nil
                                             launchOptions:launchOptions];
#if RCT_DEV
  [bridge moduleForClass:[RCTDevLoadingView class]];
#endif
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"Test"
                                            initialProperties:nil];
  ...
}
rskull commented 6 years ago

react-native: 0.50.4 same issue...

6axter82 commented 6 years ago

react-native: 0.51.0 same issue...

pigflymoon commented 6 years ago

"react": "16.2.0", "react-native": "0.52.0", same issue...

berkcoker commented 6 years ago

"react": "16.2.0", "react-native": "0.51.0", "react-native-device-info": "0.13.0"

My solution here was to move react-native-device-info out of the pod file and link it manually in the project. That seemed to solve the issue. I think another approach could be to include CxxBridge as a subspec for React in the pod file, but that requires Folly (and so boost), and that whole setup is cumbersome / takes long time. If you want a quick fix, simply remove the packages that are causing the issue out of pod.

akvsh-r commented 6 years ago

No "react-native-device-info" installed: Issue exists in 0.54.2 :

"react": "16.3.0-alpha.2", "react-native": "0.54.2", "react-native-action-button": "^2.8.4", "react-native-admob": "^2.0.0-beta.4", "react-native-animatable": "^1.2.4", "react-native-awesome-alerts": "^1.0.7", "react-native-elements": "^0.19.0", "react-native-fbsdk": "^0.7.0", "react-native-linear-gradient": "^2.4.0", "react-native-parallax-scroll-view": "^0.21.0", "react-native-photo-grid": "0.0.2", "react-native-responsive-dimensions": "^1.0.2", "react-native-snap-carousel": "^3.6.0", "react-native-vector-icons": "^4.5.0", "react-navigation": "^1.5.7"

akvsh-r commented 6 years ago

It was with the "react-native-action-button": "^2.8.4", Adding shadowStyle={{shadowOpacity: 0.9}} solved the warning..

wellyshen commented 6 years ago

Same issue here.

avinashwigroup commented 6 years ago

Same issue.
RN 0.54.4

SkrewEverything commented 6 years ago

Anybody got the solution?

The error comes even for freshly/newly created project.

"react": "16.3.1", "react-native": "0.54.4"

yogu2017 commented 6 years ago

same

MikeSilvis commented 6 years ago

+1

@antoinerousseau any update on this issue?

cmbasnett commented 6 years ago

I would not recommend the solution provided by @devburmistro. For my project, it's inclusion created some sort of race condition where this assertion error would manifest randomly on startup when running it from the simulator.

My set-up:

react-native-cli: 2.0.1
react-native: 0.53.0
nxz91 commented 6 years ago

I started having this issue just now after setting up my repo from scratch and inserting the pure js code back in there. A potential difference between the previous and this new repo is that now I'm using Cocoapods.

Anyone not using Cocoapods?

Babazon commented 6 years ago

This happened right after I added

react-native-blur

to a Share Extension view, nested within

react-native-modalbox

JungleCatSW commented 6 years ago

@Babazon are you using a debugger when this happens ?

Babazon commented 6 years ago

Sorry. I could not debug/console log from the Share Extension view, only the main app.

iorikingdom commented 6 years ago

+1

react-native-bot commented 6 years ago

Thanks for posting this! It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest release, v0.55?

Thank you for your contributions.

suprraz commented 6 years ago

@react-native-bot issue still occurring on React Native 0.55

yosimasu commented 6 years ago

@react-native-bot When using cocoapods to manage react native, the issue will show up.

versions I try 0.50.4 and 0.55.4

EthanDM commented 6 years ago

Just installed react-native-svg on React Native 0.55.3 and this issue popped up.

AlbertoMalavasi commented 6 years ago
screen shot 2018-05-30 at 16 04 07

issue still occurring on:

react-native-cli: 2.0.1 react-native: 0.55.4

tiofabby commented 6 years ago

I am having exact same warning with a fresh new created project without any code added but only Firebase dependencies injected. I am using : react: 16.3.1 react-native: 0.55.4 Thank you

nawazsk commented 6 years ago

I am having the same issue but, for me it was because of the previous terminal window running when i rerun the build from Xcode. I just quit the terminal and the simulator and run the build again, this issue got resolved.

terreb commented 6 years ago

I also have react-native-device-info installed, but the yellow message is slightly different for me: 'RCTBridge required dispatch_sync to load RCCManagerModule...'

mileung commented 6 years ago

I was going to say I get this warning when I map over an array to return new elements or pass a style prop to custom components, but now the warning seems unpredictable.

carvingpixel commented 5 years ago

Encountered this issue on OS11 as well.

I see a few people here that have mentioned using vector-icons.

imyagnesh commented 5 years ago

I also had the same issue for me i have unlink and remove react-native-device-info and now that warning is not appearing.

tompark commented 5 years ago

I had the same issue after adding react-native-vector-icons, removed it and warning went away.

nagarro-dv-main commented 5 years ago

FYI, this warning showed up today after reload with remote debugger on. Turned remote off, did reload, no warning. Turned remote back on, did reload, no warning.

adam-s commented 5 years ago

FYI, this warning showed up today after reload with remote debugger on. Turned remote off, did reload, no warning. Turned remote back on, did reload, no warning.

~After reading @mokriya comment I reloaded the debugger and it stopped showing the warning. It is possible that moving between Android and IOS emulator / simulator with the debugger tab open in the browser is causing this.~

Nope not that