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

App hangs on boot, iOS 12.2 #24023

Closed
dotconnor opened this issue Mar 19, 2019 · 11 comments
Closed

App hangs on boot, iOS 12.2 #24023

dotconnor opened this issue Mar 19, 2019 · 11 comments
Labels
Bug Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.

Comments

@dotconnor
Copy link

🐛 Bug Report

When opening in the app (at least in dev mode) the app will hang for a few minutes, then produce some errors then load.

Errors:

2019-03-19 02:22:37.682015-0400 demo[10073:2278776] NSURLConnection finished with error - code -1001
2019-03-19 02:22:37.698640-0400 demo[10073:2278776] Task <D45BEC27-481C-4363-AB5C-4FF04668971F>.<0> HTTP load failed (error code: -999 [1:89])
2019-03-19 02:22:37.704 [info][tid:main][RCTCxxBridge.mm:213] Initializing <RCTCxxBridge: 0x106c01290> (parent: <RCTBridge: 0x2815df5d0>, executor: (null))
2019-03-19 02:22:37.713366-0400 demo[10073:2278700] Initializing <RCTCxxBridge: 0x106c01290> (parent: <RCTBridge: 0x2815df5d0>, executor: (null))
2019-03-19 02:22:37.774 [info][tid:main][RCTRootView.m:293] Running application demo ({
    initialProps =     {
    };
    rootTag = 1;
})
2019-03-19 02:22:37.773706-0400 demo[10073:2278700] Running application demo ({
    initialProps =     {
    };
    rootTag = 1;
})
2019-03-19 02:22:37.786887-0400 demo[10073:2278777] [] nw_socket_handle_socket_event [C2.1:1] Socket SO_ERROR [61: Connection refused]
2019-03-19 02:22:37.846900-0400 demo[10073:2278777] [] nw_socket_handle_socket_event [C2.2:1] Socket SO_ERROR [61: Connection refused]
2019-03-19 02:22:37.847145-0400 demo[10073:2279213] [] nw_connection_get_connected_socket [C2] Client called nw_connection_get_connected_socket on unconnected nw_connection
2019-03-19 02:22:37.847158-0400 demo[10073:2279213] TCP Conn 0x280bd9bc0 Failed : error 0:61 [61]
2019-03-19 02:22:37.849843-0400 demo[10073:2279213] [] nw_socket_handle_socket_event [C3.1:1] Socket SO_ERROR [61: Connection refused]
2019-03-19 02:22:37.850253-0400 demo[10073:2279213] [] nw_socket_handle_socket_event [C3.2:1] Socket SO_ERROR [61: Connection refused]
2019-03-19 02:22:37.850388-0400 demo[10073:2278782] [] nw_connection_get_connected_socket [C3] Client called nw_connection_get_connected_socket on unconnected nw_connection
2019-03-19 02:22:37.850399-0400 demo[10073:2278782] TCP Conn 0x280bd9e00 Failed : error 0:61 [61]
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 10073, TID: 2279425, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   libobjc.A.dylib                     0x00000001adc936f4 <redacted> + 56
5   CoreMotion                          0x00000001b43db688 CoreMotion + 292488
6   CoreMotion                          0x00000001b43dbbb8 CoreMotion + 293816
7   CoreMotion                          0x00000001b43dbac8 CoreMotion + 293576
8   CoreMotion                          0x00000001b44098f8 CoreMotion + 481528
9   CoreMotion                          0x00000001b440993c CoreMotion + 481596
10  CoreFoundation                      0x00000001aea1f78c <redacted> + 28
11  CoreFoundation                      0x00000001aea1f074 <redacted> + 276
12  CoreFoundation                      0x00000001aea1a368 <redacted> + 2276
13  CoreFoundation                      0x00000001aea19764 CFRunLoopRunSpecific + 452
14  CoreFoundation                      0x00000001aea1a498 CFRunLoopRun + 84
15  CoreMotion                          0x00000001b44092d0 CoreMotion + 479952
16  libsystem_pthread.dylib             0x00000001ae699920 <redacted> + 132
17  libsystem_pthread.dylib             0x00000001ae69987c _pthread_start + 48
18  libsystem_pthread.dylib             0x00000001ae6a1dcc thread_start + 4
2019-03-19 02:22:38.010260-0400 demo[10073:2279425] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 10073, TID: 2279425, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   libobjc.A.dylib                     0x00000001adc936f4 <redacted> + 56
5   CoreMotion                          0x00000001b43db688 CoreMotion + 292488
6   CoreMotion                          0x00000001b43dbbb8 CoreMotion + 293816
7   CoreMotion                          0x00000001b43dbac8 CoreMotion + 293576
8   CoreMotion                          0x00000001b44098f8 CoreMotion + 481528
9   CoreMotion                          0x00000001b440993c CoreMotion + 481596
10  CoreFoundation                      0x00000001aea1f78c <redacted> + 28
11  CoreFoundation                      0x00000001aea1f074 <redacted> + 276
12  CoreFoundation                      0x00000001aea1a368 <redacted> + 2276
13  CoreFoundation                      0x00000001aea19764 CFRunLoopRunSpecific + 452
14  CoreFoundation                      0x00000001aea1a498 CFRunLoopRun + 84
15  CoreMotion                          0x00000001b44092d0 CoreMotion + 479952
16  libsystem_pthread.dylib             0x00000001ae699920 <redacted> + 132
17  libsystem_pthread.dylib             0x00000001ae69987c _pthread_start + 48
18  libsystem_pthread.dylib             0x00000001ae6a1dcc thread_start + 4
2019-03-19 02:22:49.439842-0400 demo[10073:2279213] [] nw_socket_handle_socket_event [C4.1:1] Socket SO_ERROR [61: Connection refused]
2019-03-19 02:22:49.440858-0400 demo[10073:2279213] [] nw_socket_connect [C4.2:1] connectx(8, [srcif=0, srcaddr=<NULL>, dstaddr=127.0.0.1:8081], SAE_ASSOCID_ANY, 0, NULL, 0, NULL, SAE_CONNID_ANY) failed: [61: Connection refused]
2019-03-19 02:22:49.441016-0400 demo[10073:2279213] [] nw_socket_connect [C4.2:1] connectx failed (fd 8) [61: Connection refused]
2019-03-19 02:22:49.441035-0400 demo[10073:2279213] [] nw_socket_connect connectx failed (fd 8) [61: Connection refused]
2019-03-19 02:22:49.441313-0400 demo[10073:2279490] [] nw_connection_get_connected_socket [C4] Client called nw_connection_get_connected_socket on unconnected nw_connection
2019-03-19 02:22:49.441345-0400 demo[10073:2279490] TCP Conn 0x280bcc0c0 Failed : error 0:61 [61]
2019-03-19 02:22:49.508 [info][tid:com.facebook.react.JavaScript] Running application "demo" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
2019-03-19 02:22:49.508350-0400 demo[10073:2279394] Running application "demo" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF

To Reproduce

  1. react-native init demo
  2. react-native run-ios --device

Expected Behavior

App doesn't hang on boot.

Environment

React Native Environment Info:
    System:
      OS: macOS 10.14.4
      CPU: (4) x64 Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
      Memory: 24.91 MB / 8.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
      Yarn: 1.14.0-20190123.1234 - ~/.yarn/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.13.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5014246
      Xcode: 10.2/10P107d - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.1 => 0.59.1 
@dotconnor
Copy link
Author

dotconnor commented Mar 19, 2019

Little Update:

When loading the app onto the device via react-native run-ios --device, the app crashes after ~10s.

When loading via xcode, the app loads, hangs for about ~30s then loads the app from what i'm assuming is main.jsbundle and the not metro bundler running on my system, it then procedes to produce the same error every ~1.5s:

2019-03-19 17:19:14.140363-0400 demo[894:181862] [] nw_socket_handle_socket_event [C69.1:1] Socket SO_ERROR [61: Connection refused]
2019-03-19 17:19:14.143603-0400 demo[894:181862] [] nw_socket_handle_socket_event [C69.2:1] Socket SO_ERROR [61: Connection refused]
2019-03-19 17:19:14.144972-0400 demo[894:181862] [] nw_connection_get_connected_socket [C69] Client called nw_connection_get_connected_socket on unconnected nw_connection
2019-03-19 17:19:14.145089-0400 demo[894:181862] TCP Conn 0x280e78000 Failed : error 0:61 [61]

EDIT: The above errors not relevant to the issue as noted here: #21030

@dotconnor
Copy link
Author

The issue appears to be when my system is connected to Wi-Fi and Ethernet, which are on two different networks.

If Ethernet is disabled, app works as expect, but if Ethernet is enabled, even if it has a lower network priority it doesn't connect.

There also doesn't appear to be a option to change to the IP to connect to, nor does it log the IP in xcode any more.

@patrickkempff
Copy link
Contributor

@dotconnor thanks for reaching out. Can you post what your AppDelegate.m looks like? Is it exactly the same as the init template?

@dotconnor
Copy link
Author

@patrickkempff Yeah, it should be the same as the template.

/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#import "AppDelegate.h"

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

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"demo"
                                            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;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end

@patrickkempff
Copy link
Contributor

patrickkempff commented Mar 19, 2019

@dotconnor what happens when you load http://<ip of the packager>:8081 in a browser on your device? Assuming the packager uses the default port 8081

@dotconnor
Copy link
Author

@patrickkempff The packager correctly binds to 0.0.0.0.
Connecting to both Wi-Fi interfaces (en1 and en6 in my case) on my device returns a document (incorrect mimetype for webkit to render), contents:

<!DOCTYPE html>
<html>
<head>
  <title>React Native</title>
</head>
<body>
  <p>React Native packager is running.</p>
  <p><a href="http://facebook.github.io/react-native/">Visit documentation</a></p>
</body>
</html>

But connecting to the ethernet interface (en0), results in connection error (as expected)

@patrickkempff
Copy link
Contributor

can you try to change:

return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

to:

return [NSURL URLWithString:@"http://<ip of the packager>:8081/index.bundle?platform=ios"];

does that yield better results?

@dotconnor
Copy link
Author

Yep! That works. Thanks!

But maybe allowing to set an IP manually should be a little bit more simipler than modifing AppDelegate.m

IP=$(ipconfig getifaddr en0)

@patrickkempff
Copy link
Contributor

@dotconnor very nice 👍 If you have any idea's on how to improve this mechanism, a PR would be really awesome! Would you mind and help us all to improve this by submitting a PR? 🥇

@GreenRidingHood
Copy link

thank you @patrickkempff that solved. sorry @dotconnor i didnt understand your solution, i dont have much xcode or RN knowledge (yet :) )

@DataGreed
Copy link

@patrickkempff which IP should I use if I debug on my device via a cable from xcode?

@facebook facebook locked as resolved and limited conversation to collaborators Mar 20, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

5 participants