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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
antoinerousseau opened this issue Oct 15, 2017 · 136 comments
Labels
Bug Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@antoinerousseau
Copy link
Contributor

antoinerousseau commented Oct 15, 2017

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
Copy link

Same here!

@eggybot
Copy link

eggybot commented Oct 15, 2017

got this yellow issue for iOS

@rizzomichaelg
Copy link

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
Copy link
Contributor

jozan commented Oct 16, 2017

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
Copy link

minikin commented Oct 16, 2017

+1

1 similar comment
@mkozhukharenko
Copy link

+1

@antoinerousseau
Copy link
Contributor Author

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

@dantman
Copy link
Contributor

dantman commented Nov 7, 2017

Same issue. Here are the packages I use:

  • react-native-device-info
  • react-native-interactable
  • react-native-sensitive-info
  • react-native-snackbar
  • react-native-splash-screen
  • react-native-svg
  • react-native-vector-icons

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

  • A bug in react-native itself
  • A bug in react-native-device-info
  • Multiple bugs in libraries other than react-native-device-info

@disjfa
Copy link

disjfa commented Nov 8, 2017

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
Copy link

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

@WhoJave
Copy link

WhoJave commented Nov 10, 2017

Same issue... Do u have any solutions ?

@SMJ93
Copy link

SMJ93 commented Nov 14, 2017

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

@bullantt
Copy link

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
Copy link

fishmwei commented Nov 16, 2017

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

anybody resolved it ??

@thejacobseely
Copy link

thejacobseely commented Nov 16, 2017

@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
Copy link
Contributor

@dantman
Copy link
Contributor

dantman commented Nov 20, 2017

react-native-device-info/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
Copy link
Contributor

mattijsf commented Nov 28, 2017

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
Copy link

grossingdev commented Dec 10, 2017

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
Copy link

rskull commented Dec 15, 2017

react-native: 0.50.4
same issue...

@6axter82
Copy link

react-native: 0.51.0
same issue...

@pigflymoon
Copy link

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

@berkcoker
Copy link

berkcoker commented Jan 17, 2018

"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
Copy link

akvsh-r commented Mar 17, 2018

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
Copy link

akvsh-r commented Mar 17, 2018

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

@wellyshen
Copy link

Same issue here.

@avinashwigroup
Copy link

Same issue.
RN 0.54.4

@SkrewEverything
Copy link

Anybody got the solution?

The error comes even for freshly/newly created project.

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

@yogu2017
Copy link

yogu2017 commented Apr 9, 2018

same

@MikeSilvis
Copy link

MikeSilvis commented Apr 13, 2018

+1

@antoinerousseau any update on this issue?

leotm added a commit to leotm/react-native-template-new-architecture that referenced this issue Jul 17, 2021
RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks

facebook/react-native#16376
@ivantacca
Copy link

Add this in your /ios/YourAppName/AppDelegate.m, right after #import "AppDelegate.h"

#if RCT_DEV
#import <React/RCTDevLoadingView.h>
#endif

@safaiyeh
Copy link
Contributor

safaiyeh commented Aug 2, 2021

If you are getting one of these errors:
RCTBridge required dispatch_sync to load RCTDevLoadingView
Use of undeclared identifier 'jsCodeLocation'
Use of undeclared identifier 'RCTDevLoadingView'

Here's a full solution:
Update the app-name/ios/AppName/AppDelegate.m file with following

#import "AppDelegate.h"

// NEW CODE

// put this condition after AppDelegate.h import
#if RCT_DEV
#import <React/RCTDevLoadingView.h>
#endif

// END

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  // NEW CODE

  NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.js" fallbackResource:nil];

  RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation
                                              moduleProvider:nil
                                               launchOptions:launchOptions];
  #if RCT_DEV
   [bridge moduleForClass:[RCTDevLoadingView class]];
  #endif

  // END

  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"TempleWallet"
                                            initialProperties:nil];
  ...

Feel free to open a PR for this!

@KrisLau
Copy link

KrisLau commented Aug 4, 2021

If you are getting one of these errors:
RCTBridge required dispatch_sync to load RCTDevLoadingView
Use of undeclared identifier 'jsCodeLocation'
Use of undeclared identifier 'RCTDevLoadingView'

Here's a full solution:
Update the app-name/ios/AppName/AppDelegate.m file with following

#import "AppDelegate.h"

// NEW CODE

// put this condition after AppDelegate.h import
#if RCT_DEV
#import <React/RCTDevLoadingView.h>
#endif

// END

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  // NEW CODE

  NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.js" fallbackResource:nil];

  RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation
                                              moduleProvider:nil
                                               launchOptions:launchOptions];
  #if RCT_DEV
   [bridge moduleForClass:[RCTDevLoadingView class]];
  #endif

  // END

  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"TempleWallet"
                                            initialProperties:nil];
  ...

Doing this seems to mess up expo unimodules for me. My error is coming from https://github.com/Andr3wHur5t/react-native-keyboard-spacer so I might just uninstall that

@haibert
Copy link

haibert commented Oct 19, 2021

Guys i'm getting this in Expo v43. My app works in development with my custom dev client but crashes in production. Does anyone know what the solution is for expo users? id greatly appreciate any guidance. #14766

@mwegener-com
Copy link

mwegener-com commented Nov 3, 2021

same problem in expo dev client.
@haibert do you have any solution?

@haibert
Copy link

haibert commented Nov 3, 2021

@mwegener-com according to some people it is fixable modifying the App.Delegate.m. Mentioned by @safaiyeh for example. To modify this you can use the withAppDelegate from @expo/config-plugins to make the modifications. it'll look something like this.

// in your project root directory create filed named withIosAppDelegate.js 
const { withAppDelegate } = require('@expo/config-plugins')

const modAppDelegate = (content) => {
// modify content of AppDelegate.m here and return it, its basic string manipulation.
// you can also console.log things here to see your code is doing
    return content
}

module.exports = (config) => {
    return withAppDelegate(config, async (config) => {
// the line below will feed the content of the AppDelegate.m to your function made above ^ "modAppDelegate", from there you will conduct needed manipulations and return it.
        config.modResults.contents = modAppDelegate(config.modResults.contents)
        return config
    })
}
// in your app.js
{
    "expo": {
     ...
        "plugins": [
            "./withIosAppDelegate.js"
        ]
    }
}

then make sure you make a commit and run expo prebuild -p ios --clean
this will apply your changes to the AppDelegate.m and if you are console logging things you will see your changes made
if the changes are made correctly go ahead and build your new build and you are set.

trying to learn how to create a plugin by reading the expo docs is very confusing but I was taught by someone who knew how to use them and I hope this helps. Basically you are passed the content of the native file you need to manipulate as a string, and you must use regex or any means to do string manipulation and add or remove the lines of code you want, then simply return the string. docs

btw I have been able to avoid any problems by first launching the dev client on the simulator or my phone and THEN pressing i on my console to run the project, this way the dev client doesn't crash.. if this works for you you wont even need to do any of the step above..

@mwegener-com
Copy link

mwegener-com commented Nov 3, 2021

@haibert It wouldn't be my first config plugin, but have you already finished it and might share your solution?

@haibert
Copy link

haibert commented Nov 3, 2021

@mwegener-com I have not created a config plug in because even though the warning comes I rarely get any crashes because of it. If you do create it I would appreciate the share

@vbylen
Copy link

vbylen commented Nov 19, 2021

I'm getting the same error

@fritzfr
Copy link

fritzfr commented Nov 23, 2021

I have no idea what the meaning of the warning is, but this makes it go away:

https://amanhimself.dev/blog/rctbridge-required-dispatch-sync-to-load-warning/

@liquidvisual
Copy link

None of this works in 2022, on a fresh install of React Native 0.67.3

@billnbell
Copy link
Contributor

0.67.3 this does not help. What does it mean?

@W-Lawless
Copy link

W-Lawless commented Apr 21, 2022

Hello,

Using "react-native": "0.64.3" I am seeing this issue after installing a native module (Agora Livestreaming SDK) and running expo run:ios Mac Monterey & Xcode 13.3

I added two string values to Info.plist for the enable mic/camera permission text.

Besides that I have no other modules in project, and only imported expo libraries such as blurview for basic layout features.

I am seeing this issue now on loading the app through Metro now that I am in a bare workflow

@l2aelba
Copy link

l2aelba commented Jun 14, 2022

I'm from 2030 and this still does not fix. 😏

@Nziranziza
Copy link

Nziranziza commented Jul 24, 2022

I am experiencing the same issue as well

@YaoHuiJi
Copy link

YaoHuiJi commented Sep 28, 2022

... a new created 0.70.1 project has this issue too, it's funny, cause my 4 years old project doesn't have this issue.

I wonder is it safe to ignore this warning?

@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Mar 27, 2023
@github-actions
Copy link

github-actions bot commented Apr 3, 2023

This issue was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this as completed Apr 3, 2023
@facebook facebook locked as resolved and limited conversation to collaborators Apr 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests