Skip to content

Dev Mode app crashed for offline mode #10533

Closed

Description

@atcfu

Description

It appears that the [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:NULL] in the RCTBundleURLProvider.m crashed in iOS 10, if the dev app running in offline/other network mode.
I think we need to check the error before parsing the data.

(BOOL)isPackagerRunning:(NSString *)host
{
NSURL *url = [serverRootWithHost(host) URLByAppendingPathComponent:@"status"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSURLResponse *response;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:NULL];
NSString *status = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
return [status isEqualToString:@"packager-status:running"];
}

Reproduction

  1. deploy the dev version of your app
  2. switch network and reopen

Additional Information

  • React Native version: 0.35
  • Platform: iOS 10.0
  • Operating System: MacOS10.12

Activity

  1. lacker commented on Oct 25, 2016

    @lacker
    Contributor

    I don't understand your reproduction steps here. I can deploy the dev version of an app, switch the network, and have it still work. Can you provide a more specific explanation of how to reproduce this bug?

  2. atcfu commented on Oct 25, 2016

    @atcfu
    Author

    Basically, if I disconnected my app and switch to 4G, then kill app and reopen, the crash happened, from the crash log in Devices, it seems the sendSynchronousRequest has some problems, please advice.


    Date/Time: 2016-10-25 11:13:05.0675 +0800
    Launch Time: 2016-10-25 11:12:44.8976 +0800
    OS Version: iPhone OS 10.0.2 (14A456)
    Report Version: 104

    Exception Type: EXC_CRASH (SIGKILL)
    Exception Codes: 0x0000000000000000, 0x0000000000000000
    Exception Note: EXC_CORPSE_NOTIFY
    Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d
    Triggered by Thread: 0

    Filtered syslog:
    None found

    Thread 0 name: Dispatch queue: com.apple.main-thread
    Thread 0 Crashed:
    0 libsystem_kernel.dylib 0x00000001903f41a8 semaphore_wait_trap + 8
    1 libdispatch.dylib 0x00000001902df7ec _dispatch_semaphore_wait_slow + 216
    2 CFNetwork 0x0000000191ae0c58 CFURLConnectionSendSynchronousRequest + 284
    3 CFNetwork 0x0000000191b0c1dc +[NSURLConnection sendSynchronousRequest:returningResponse:error:] + 120
    4 duolamarket 0x0000000100360934 0x1000d4000 + 2672948
    5 duolamarket 0x0000000100360c2c 0x1000d4000 + 2673708
    6 duolamarket 0x0000000100360e3c 0x1000d4000 + 2674236
    7 duolamarket 0x0000000100361000 0x1000d4000 + 2674688
    8 duolamarket 0x0000000100122d4c 0x1000d4000 + 322892
    9 duolamarket 0x00000001001228b8 0x1000d4000 + 321720
    10 UIKit 0x00000001972ff42c -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 400
    11 UIKit 0x000000019750fb70 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3524
    12 UIKit 0x00000001975158e0 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1656
    13 UIKit 0x000000019752a080 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke.3134 + 48
    14 UIKit 0x00000001975128c4 -[UIApplication workspaceDidEndTransaction:] + 168
    15 FrontBoardServices 0x0000000192fe58bc FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 36
    16 FrontBoardServices 0x0000000192fe5728 -[FBSSerialQueue _performNext] + 176
    17 FrontBoardServices 0x0000000192fe5ad0 -[FBSSerialQueue _performNextFromRunLoopSource] + 56
    18 CoreFoundation 0x00000001913f2278 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 24
    19 CoreFoundation 0x00000001913f1bc0 __CFRunLoopDoSources0 + 524
    20 CoreFoundation 0x00000001913ef7c0 __CFRunLoopRun + 804
    21 CoreFoundation 0x000000019131e048 CFRunLoopRunSpecific + 444
    22 UIKit 0x00000001972f85dc -[UIApplication _run] + 608
    23 UIKit 0x00000001972f3360 UIApplicationMain + 208
    24 duolamarket 0x0000000100136e78 0x1000d4000 + 405112
    25 libdyld.dylib 0x00000001903005b8 start + 4

    Thread 1:
    0 libsystem_pthread.dylib 0x00000001904d4db0 start_wqthread + 0

    Thread 2:
    0 libsystem_pthread.dylib 0x00000001904d4db0 start_wqthread + 0

    Thread 3:
    0 libsystem_pthread.dylib 0x00000001904d4db0 start_wqthread + 0

  3. lacker commented on Oct 26, 2016

    @lacker
    Contributor

    Does this happen with just a blank new app?

  4. satya164 commented on Oct 27, 2016

    @satya164
    Contributor

    I don't think we're caching the bundle on iOS, in which case this is expected behaviour?

  5. wafisher commented on Nov 1, 2016

    @wafisher

    +1. Attaching a stack trace of the thread (main thread) that causes iOS to kill the app. The app never opens and it's killed about 10 seconds after clicking on the app icon in iOS. I replaced my app name with AppName.

    0   libsystem_kernel.dylib          0x0000000184ac41a8 semaphore_wait_trap + 8
    1   libdispatch.dylib               0x00000001849af7ec _dispatch_semaphore_wait_slow + 216
    2   CFNetwork                       0x00000001861b0c58 CFURLConnectionSendSynchronousRequest + 284
    3   CFNetwork                       0x00000001861dc1dc +[NSURLConnection sendSynchronousRequest:returningResponse:error:] + 120
    4   AppName                         0x00000001001125a0 -[RCTBundleURLProvider isPackagerRunning:] (RCTBundleURLProvider.m:75)
    5   AppName                         0x0000000100112848 -[RCTBundleURLProvider guessPackagerHost] (RCTBundleURLProvider.m:91)
    6   AppName                         0x0000000100112a58 -[RCTBundleURLProvider packagerServerHost] (RCTBundleURLProvider.m:105)
    7   AppName                         0x0000000100112c1c -[RCTBundleURLProvider jsBundleURLForBundleRoot:fallbackResource:] (RCTBundleURLProvider.m:122)
    8   AppName                         0x00000001000450ac -[AppDelegate application:didFinishLaunchingWithOptions:] (AppDelegate.m:24)
    9   UIKit                           0x000000018b9cf42c -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 400
    10  UIKit                           0x000000018bbdfb70 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3524
    11  UIKit                           0x000000018bbe58e0 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1656
    
  6. lacker commented on Nov 2, 2016

    @lacker
    Contributor

    @wafisher It's unclear to me what you're +1ing. Are you agreeing with @satya164 saying that this is expected behavior since we aren't caching the bundle on iOS?

  7. wafisher commented on Nov 2, 2016

    @wafisher

    Sorry, +1 on experiencing the problem and providing a stack trace with line numbers. Running version 0.34.

  8. palmsey commented on Nov 11, 2016

    @palmsey

    This is happening for me too, running 0.36 on iOS 10.1.1. I think the same issue is described here: #10187

    For me, I'm not able to get past the launch screen when wifi is disabled. The iOS crash log is the same as @wafisher reported.

  9. dennislaupman commented on Dec 9, 2016

    @dennislaupman

    Hi Guy's,

    I've got same problem :(

    react-native-cli: 0.2.0
    react-native: 0.39.1

    App crashed after switching network. For example from Wifi to 4G.

    You can reproduce it by:

    opening app
    Switching form wifi to 4G
    Close app
    Reopen app

    After a freeze of a few seconds the app crashed.

  10. alejandromizraji commented on Jan 29, 2017

    @alejandromizraji

    I've got same problem

    react-native-cli: 2.0.1
    react-native: 0.40.0

    When i launch the app with lte it crashes

  11. lacker commented on Feb 7, 2017

    @lacker
    Contributor

    I think this is a dupe of #10187 so I am going to close this one. A pull request to improve the error-detection behavior in this bit of code would be great too!

  12. locked as resolved and limited conversation to collaborators on Jul 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions