FG
📱 Mobile & Cross-Platform

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

Freshabout 19 hours ago
Mar 14, 20260 views
Confidence Score95%
95%

Problem

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 <img width="432" alt="capture d ecran 2017-10-15 12 49 45" src="https://user-images.githubusercontent.com/160279/31584109-0fc35620-b1a8-11e7-88c2-cbbdd383fc84.png"> 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

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Refactor RCTBridge Initialization to Avoid Deadlocks

Medium Risk

The warning occurs due to the RCTBridge requiring a synchronous dispatch to load the RCTDevLoadingView, which can lead to deadlocks if the main thread is blocked. This is particularly problematic in scenarios where the app's startup sequence is not properly managed, leading to race conditions.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Update React Native Version

    Upgrade to a more recent version of React Native where this issue may have been addressed. Check the changelog for any fixes related to RCTBridge initialization.

    bash
    npm install react-native@latest
  2. 2

    Modify AppDelegate.m for Asynchronous Loading

    In the AppDelegate.m file, ensure that the RCTBridge is initialized asynchronously to prevent blocking the main thread. This can be done by using a dispatch queue.

    objective-c
    dispatch_async(dispatch_get_main_queue(), ^{
        self.bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
    });
  3. 3

    Implement Error Handling for Bridge Initialization

    Add error handling during the initialization of the RCTBridge to catch any potential issues that could lead to deadlocks. This will help in diagnosing the problem if it persists.

    objective-c
    if (!self.bridge) {
        NSLog(@"Failed to initialize RCTBridge");
    }
  4. 4

    Test on Multiple Devices

    Run the application on multiple iOS devices and simulators to ensure that the warning does not appear consistently. This will help confirm that the changes have resolved the issue.

Validation

To confirm the fix, start the app multiple times on different devices and check the console logs for the absence of the warning message regarding RCTBridge and RCTDevLoadingView. Ensure that the app loads without any deadlocks.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

react-nativemobileiosandroidplatform:-iosstalebug