facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
117.14k stars 24.08k 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

solonifer commented 5 years ago

iOS 12, RN 0.57.0 same issue.

shinriyo commented 5 years ago

how to resolve? or ignore is?

import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings(['RCTBridge']);
FullstackJack commented 5 years ago

Yes, I am having this issue as well after adding react-native-video, but what does it mean? It doesn't seem to prevent videos from playing. Also why are all of these third-party components causing the error? Are we missing something in developing our native modules?

2hyjun commented 5 years ago

Getting same issue on iOS 12.1, RN 0.57.4 without react-native-device-info

bashirpour commented 5 years ago

I have some issue

"lodash": "^4.17.10",
"react": "16.4.1",
"react-native": "0.56.0",
"react-native-check-box": "^2.1.0",
"react-native-collapsible": "^1.2.1",
"react-native-elements": "^0.19.1",
"react-native-google-analytics-bridge": "^5.8.0",
"react-native-google-places-autocomplete": "^1.3.9",
"react-native-map-clustering": "^1.3.0",
"react-native-maps": "^0.21.0",
"react-native-masked-text": "^1.7.2",
"react-native-modal-picker": "0.0.16",
"react-native-onesignal": "^3.2.8",
"react-native-simple-radio-button": "^2.7.2",
"react-native-svg": "^8.0.0",
"react-native-ui-kitten": "^3.0.1",
"react-native-vector-icons": "^5.0.0",
"react-navigation": "^2.11.2",
"rn-sliding-up-panel": "^1.2.1",
"victory-native": "^30.5.0"
srichallamalla935 commented 5 years ago

In IOS getting "RCTBridge required dispatch_snyc to load RCTDevLoadingView This may lead to deadlocks."

achmadk commented 5 years ago

Maybe you should Project -> Clean in your Xcode, then re-run your application.

aleclarson commented 5 years ago

I've confirmed that this comment is the solution. Thank you @mattijsf!

Find your RCTBridgeDelegate and override the extraModulesForBridge method.

Objective-C

@interface MyBridgeDelegate : NSObject <RCTBridgeDelegate>
@end

@implementation MyBridgeDelegate

- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
  return @[
#if RCT_DEV
    [bridge moduleForClass:[RCTDevLoadingView class]],
#endif
  ];
}

@end

Swift 4

class MyBridgeDelegate: NSObject, RCTBridgeDelegate {
  func extraModules(for bridge: RCTBridge!) -> [RCTBridgeModule]! {
    var modules: [Any]! = []
    if RCT_DEV == 1 {
      modules.append(bridge.module(for: RCTDevLoadingView.self))
    }
    return modules as? [RCTBridgeModule]
  }
}
kodayashi commented 5 years ago

Repro on iOS12, RN 0.57.8

EvanMaFYH commented 5 years ago

image my dependency,the same issue

ccorcos commented 5 years ago

@aleclarson what exactly does that code do?

aleclarson commented 5 years ago

@ccorcos It loads the RCTDevLoadingView earlier, so it doesn't have to block the main thread when it's loaded by RN. This comment might be an easier solution for you.

mikehardy commented 5 years ago

Not sure if this is still happening for others but it still happening for me with RN 0.57.8 + iOS 11.3 (at least)

I'm using the change from the comment above by @devburmistro successfully

rtt63 commented 5 years ago

Facing this issue

RN 0.58.3 iOS 11.4, 12.1

and it does lead to deadlock. It happens to me when I closing custom modal

I haven't had this on previous 0.57.8 which was just fine

oferRounds commented 5 years ago

Same here, getting this after upgrading to RN 0.58.3

oferRounds commented 5 years ago

my exact error is: Unable find module for DevLoadingView, the solutions above do not fix it for me

screen shot 2019-01-30 at 0 54 04
oferRounds commented 5 years ago

Seems related to this commit, which has in fact added on RN 0.58.3

https://github.com/facebook/react-native/commit/d7a0c44590bcf3fb9d055aeae3391d5bcd7e21be#diff-a2a67635fffd7b690d14dc17ae563a71

superguineapig commented 5 years ago

I am experiencing the same "Unable to find module for DevLoadingView" issue as @oferRounds after upgrading to RN 0.58.3 today.

It seems to trigger when an app is first opened in the simulator. Subsequent reloads (cmd-R) do not present the error.

EDIT: filed a separate issue for this specific error: #23235

noahtallen commented 5 years ago

I can also confirm that this is still an issue on iOS with 0.58.3.

Some interesting observations:

Edit: I can confirm that this workaround is still a viable solution.

prodoxx commented 5 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];
  ...
}

This worked for me.

willmanio commented 5 years ago

Has anyone been able to register a custom RCTBridgeDelegate while using react-native-navigation? You should be able to pass a delegate via the bridgeManagerDelegate param, but it seems broken (the RCTBridge provided to extraModulesForBridge is always nil).

joelgetaction commented 5 years ago

I just started getting this immediately after adding react-native-device-info on RN 0.58.6 and iOS 12.

joelgetaction commented 5 years ago

OK, this comment seems to have fixed it for me.

wibb36 commented 5 years ago

React Native 0.59.1

I start seeing this warning right after installing react-native-device-info as well, any real solution?

fungilation commented 5 years ago

I'm seeing this randomly as well, and I have made no changes in my app code other than what's necessary (config) to make everything work again, in upgrading from RN 0.57.8 to 0.59.5. In my case, lib in question is CodePush, with 2 yellowbox warnings:

RCTBridge required dispatch_sync to load CodePush. This may lead to deadlocks and Required dispatch_sync to load constants for CodePush. This may lead to deadlocks

This issue is long. I assume nailing down the root cause is still a mystery? Let me know what other debug info I can provide to help.

My package.json: ```js { "name": "wonderswipe", "version": "0.0.1", "private": true, "eslintConfig": { "parserOptions": { "ecmaVersion": 7, "sourceType": "module", "ecmaFeatures": { "jsx": true } }, "env": { "browser": false, "node": true }, "plugins": [ "react", "react-native", "react-hooks" ], "rules": { "comma-dangle": [ 2, "always-multiline" ], "semi": [ 2, "never" ], "react-native/no-unused-styles": 2, "react-native/split-platform-components": 2, "react-hooks/rules-of-hooks": "error" } }, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "postinstall": "patch-package" }, "dependencies": { "@postlight/mercury-parser": "^2.0.0", "@react-native-community/async-storage": "^1.3.3", "@react-native-community/viewpager": "^1.1.6", "babel-plugin-idx": "^2.4.0", "buffer": "^5.2.1", "he": "^1.1.0", "idx": "^2.5.5", "lodash": "^4.17.2", "moment": "^2.19.0", "moment-timezone": "^0.5.10", "node-summary": "../node-summary", "react": "16.8.3", "react-native": "^0.59.4", "react-native-actionsheet": "^2.4.2", "react-native-blur": "^3.2.0", "react-native-cached-image": "../react-native-cached-image", "react-native-cheerio": "^1.0.0-rc.4", "react-native-code-push": "^5.3", "react-native-custom-tabs": "^0.1.7", "react-native-easy-toast": "^1.0.9", "react-native-firebase": "^5.3.1", "react-native-fit-image": "^1.4.8", "react-native-flanimatedimage": "^0.4.0", "react-native-highlight-words": "^1.0.1", "react-native-keep-awake": "^4.0.0", "react-native-linear-gradient": "^2.0.0", "react-native-modal-dropdown": "^0.6.2", "react-native-modalbox": "^1.6.0", "react-native-orientation": "^3.1.3", "react-native-parallax-scroll-view": "../react-native-parallax-scroll-view", "react-native-rate": "^1.0.8", "react-native-safari-view": "^2.0.0", "react-native-sentry": "^0.42.0", "react-native-sha256": "^1.1.1", "react-native-status-bar-size": "^0.3.2", "react-native-swiper": "^1.5.14", "react-native-tooltip": "^5.2.0", "react-native-tts": "^3.0.0", "react-native-vector-icons": "^6.4.2", "react-native-webview": "^5.7.0", "react-native-webview-bridge": "^0.40.1", "react-redux": "^7.0.1", "redux": "^4.0.0", "redux-thunk": "^2.1.0" }, "devDependencies": { "babel-eslint": "^10.0.1", "eslint": "^5.15.1", "eslint-plugin-react": "^7.12.4", "eslint-plugin-react-hooks": "^1.0.1", "eslint-plugin-react-native": "^3.6.0", "patch-package": "^6.1.2", "postinstall-postinstall": "^2.0.0", "redux-logger": "^3.0.6" }, "resolutions": { "babel-core": "7.0.0-bridge.0" } } ```

image

numandev1 commented 5 years ago

i fixed this error by @grossingdev comment. but after updating react-native to 0.59.8 version. this error has come again

bn3t commented 5 years ago

At react-native 0.59.3, here is what the code should look like to workaround the problem:

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  #if RCT_DEV
    [bridge moduleForClass:[RCTDevLoadingView class]];
  #endif
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"YourAppName"
                                            initialProperties:nil];
rizwanellahi commented 5 years ago

Facing the same warning after updating the AppDelegate.m file while Integrating the react-native-maps google map in ios App. "react-native": "0.59.5"

amitkumar3968 commented 5 years ago

For me -- this worked --- "react": "16.8.3", "react-native": "0.59.9", AppDelegate.m file

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

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
//  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
//                                                   moduleName:@"mobileapp"
//                                            initialProperties:nil];

  NSURL *theurl ;
#if DEBUG
  theurl = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  theurl = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif

  RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:theurl
                                            moduleProvider:nil
                                             launchOptions:launchOptions];
#if RCT_DEV
  [bridge moduleForClass:[RCTDevLoadingView class]];
#endif
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"mobileapp"
                                            initialProperties:nil];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}
sudomann commented 4 years ago

@amitkumar3968 format your comment as code

Crare commented 4 years ago

I just got similar error:

Screenshot 2019-07-23 at 10 27 04
my package.json:
``` { "name": "auth", "version": "0.0.1", "private": true, "scripts": { "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "firebase": "^6.3.1", "react": "16.8.6", "react-native": "0.60.0" }, "devDependencies": { "@babel/core": "7.5.0", "@babel/runtime": "7.5.0", "@react-native-community/eslint-config": "0.0.3", "babel-jest": "24.8.0", "eslint": "6.0.1", "jest": "24.8.0", "metro-react-native-babel-preset": "0.54.1", "react-test-renderer": "16.8.6" }, "jest": { "preset": "react-native" } } ```

Reload fixed it, but seems something isn't right if this happens randomly.

nerami commented 4 years ago

This issue only happens to me when I deactivate the debugger. When opening the Perf Monitor, I noticed that the RAM goes from ±100MB to ±300MB after deactivating.

With debugger:

Screen Shot 2019-07-25 at 9 07 45 AM

Without debugger:

Screen Shot 2019-07-25 at 9 08 09 AM

The proposed workaround does not work in my case, since it only stops displaying the warning, but it does not solve the problem with memory.

nerami commented 4 years ago

I wonder if this problem would affect the performance of the app in release mode.

LinusU commented 4 years ago

The aforementioned workaround solved this problem for me as well, on React Native 0.59.10:

diff --git a/ios/Foo/AppDelegate.m b/ios/Foo/AppDelegate.m
index e446e79..2c28719 100644
--- a/ios/Foo/AppDelegate.m
+++ b/ios/Foo/AppDelegate.m
@@ -18,6 +18,11 @@

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

+// https://github.com/facebook/react-native/issues/16376#issuecomment-350523177
+#if RCT_DEV && __has_include(<React/RCTDevLoadingView.h>)
+#import <React/RCTDevLoadingView.h>
+#endif
+
 @implementation AppDelegate

@@ -39,6 +44,13 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

   RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
+
+  // https://github.com/facebook/react-native/issues/16376#issuecomment-350523177
+  #if RCT_DEV && __has_include(<React/RCTDevLoadingView.h>)
+  [bridge moduleForClass:[RCTDevLoadingView class]];
+  #endif
+
   RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"Foo" initialProperties:nil];
   rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

The only difference here is that I matched the exact same logic for loading it (the RCT_DEV && __has_include(<React/RCTDevLoadingView.h>) part)...

fungilation commented 4 years ago

Just got 2 with react-native-firebase. Happens rarely but: image image

richardhyatt commented 4 years ago

I was able to re-create this issue by adding app icons to the Images.xcassets/AppIcon.appiconset directory of my newly created test project using react-native 0.61.2. Adding the lines of code mention in this issue solved the issue for me.

hushicai commented 4 years ago

react-native 0.59.10 same issue.

unutoiul commented 4 years ago

same issue here!! any body solved this problem?

Tale-Dev commented 4 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];
  ...
}

this workaround solved the warning. Thank you very much.

rizaldirnm commented 4 years ago

Same issue, but if I delete block of code componentDidUpdate, this warning dissappear. But but but but I need componentDidUpdate.

Gregory-Canonne commented 4 years ago

first : open Xcode, normaly Xcode answer if you want install a component : click install

When you update macOS software, you must open Xcode for update

LPitonakova commented 4 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];
  ...
}

@grossingdev what is the jsCodeLocation please? I know it's supposed to be a URL but what should it point to?

abdi4 commented 4 years ago

Just got 2 with react-native-firebase. Happens rarely but: image image

Firebase is causing this error for me. Mind sharing how you solved it? @fungilation

Zloka commented 4 years ago

@abdi4 I just ran into this too, did you manage to solve it?

abdi4 commented 4 years ago

@zloka no this happens randomly and im not able to recreate it

rogic89 commented 4 years ago

Simplest way to ignore this or any other warning is

import { YellowBox } from 'react-native';

YellowBox.ignoreWarnings([
    'RCTBridge'
]);
IdrisHanafi commented 4 years ago

This issue arises for me non-deterministically. The only fix I have whenever it does, is to delete the app from my device and re-run.

lbagga2x commented 4 years ago

Swift Solution:

let bridge = RCTBridge(bundleURL: jsCodeLocation, moduleProvider: nil, launchOptions: nil)

if RCT_DEV

    bridge?.module(for: RCTDevLoadingView.self)
    #endif
    let rootView = RCTRootView(bridge: bridge!, moduleName: "AppMain", initialProperties: nil)
stale[bot] commented 3 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

sospedra commented 3 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

Here's your activity. The warning continue to pops up in fresh new apps.