apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 987 forks source link

Cordova-iOS 6.2.0 App crashes iPad but works fine on iPhone #NSInternalInconsistencyException #1314

Closed cemerson closed 1 year ago

cemerson commented 1 year ago

Bug Report

Problem

My app fails crashes with a NSInternalInconsistencyException (or NSBundle) error on startup on iPad (device and iOS simulator) but works fine on iPhone (device and simulator).

App DOES loads up fine on iPhone 7-14 on iOS simulator or device:

App DOES NOT load up on iPad on iOS simulator or device:

What is expected to happen?

What does actually happen?

Information

Log from an iPad run crash (same for device or iOS simulator):

2023-04-18 11:21:51.787010-0400 MyApp[71492:5068746] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/myusername/Library/Developer/CoreSimulator/Devices/Device-ID-Here/data/Containers/Bundle/Application/My-App-ID-Here/MyApp.app> (loaded)' with name 'Main''
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff20421af6 __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007fff20177e78 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff204219d4 -[NSException initWithCoder:] + 0
    3   UIKitCore                           0x00007fff2429677b -[UINib instantiateWithOwner:options:] + 495
    4   UIKitCore                           0x00007fff2429770a -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 147
    5   UIKitCore                           0x00007fff2469b2ec -[UIApplication _loadMainNibFileNamed:bundle:] + 75
    6   UIKitCore                           0x00007fff2469b992 -[UIApplication _loadMainInterfaceFile] + 274
    7   UIKitCore                           0x00007fff2469a463 -[UIApplication _runWithMainScene:transitionContext:completion:] + 971
    8   UIKitCore                           0x00007fff23cc36f7 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 122
    9   UIKitCore                           0x00007fff24251d1e _UIScenePerformActionsWithLifecycleActionMask + 88
    10  UIKitCore                           0x00007fff23cc4206 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 198
    11  UIKitCore                           0x00007fff23cc3cca -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 474
    12  UIKitCore                           0x00007fff23cc4037 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 819
    13  UIKitCore                           0x00007fff23cc38cb -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 345
    14  UIKitCore                           0x00007fff23ccbb63 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 178
    15  UIKitCore                           0x00007fff2415b613 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 871
    16  UIKitCore                           0x00007fff2426e5c6 _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 240
    17  UIKitCore                           0x00007fff23ccb869 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 361
    18  UIKitCore                           0x00007fff23aee75f __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 797
    19  UIKitCore                           0x00007fff23aed209 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 253
    20  UIKitCore                           0x00007fff23aee398 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 208
    21  UIKitCore                           0x00007fff24698a0c -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 508
    22  UIKitCore                           0x00007fff24183a1f -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 358
    23  FrontBoardServices                  0x00007fff25aa70ae -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 391
    24  FrontBoardServices                  0x00007fff25acfb41 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.176 + 102
    25  FrontBoardServices                  0x00007fff25ab4ad5 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 209
    26  FrontBoardServices                  0x00007fff25acf80f __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 352
    27  libdispatch.dylib                   0x00000001030fc9c8 _dispatch_client_callout + 8
    28  libdispatch.dylib                   0x00000001030ff910 _dispatch_block_invoke_direct + 295
    29  FrontBoardServices                  0x00007fff25af57a5 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
    30  FrontBoardServices                  0x00007fff25af548b -[FBSSerialQueue _targetQueue_performNextIfPossible] + 433
    31  FrontBoardServices                  0x00007fff25af5950 -[FBSSerialQueue _performNextFromRunLoopSource] + 22
    32  CoreFoundation                      0x00007fff2039038a __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    33  CoreFoundation                      0x00007fff20390282 __CFRunLoopDoSource0 + 180
    34  CoreFoundation                      0x00007fff2038f764 __CFRunLoopDoSources0 + 248
    35  CoreFoundation                      0x00007fff20389f2f __CFRunLoopRun + 878
    36  CoreFoundation                      0x00007fff203896d6 CFRunLoopRunSpecific + 567
    37  GraphicsServices                    0x00007fff2c257db3 GSEventRunModal + 139
    38  UIKitCore                           0x00007fff24696cf7 -[UIApplication _run] + 912
    39  UIKitCore                           0x00007fff2469bba8 UIApplicationMain + 101
    40  MyApp                            0x0000000102cdafc6 main + 54
    41  ???                                 0x000000010816e41f 0x0 + 4430685215
)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/myusername/Library/Developer/CoreSimulator/Devices/Device-ID-Here/data/Containers/Bundle/Application/My-App-ID-Here/MyApp.app> (loaded)' with name 'Main''
terminating with uncaught exception of type NSException
CoreSimulator 857.14 - Device: iPad Air 14 (Device-ID-Here) - Runtime: iOS 14.4 (18D46) - DeviceType: iPad Air (3rd generation)
(lldb) 

Here's a screenshot of what XCode displays when the crash occurs - no idea what I'm looking at here: image

Also side note/FYI - the app still works fine on Android

Command or Code

No code changes between when the app works or doesn't work - it's simply based on which iOS iPhone Simulator I use

Environment, Platform, Device

Version information

Checklist

PS: Sorry to post another issue again so soon - hoping this isn't another user-error (like my last which @breautek was so kind to help me sort out) but apologies in advance if so.

breautek commented 1 year ago

I'm not 100% sure but it feels like an issue with the storyboard/splashscreen.

Can you reproduce this with a sample hello world app, copying your splashscreen configuration? If so, share the config.xml for the sample hello world app and someone can tell you if it looks okay or if there are any problems that might explain the behaviour.

cemerson commented 1 year ago

Thanks, @breautek (we meet again). I tried your idea and, sadly, my hello world app works on both iPad and iPhone using my config.xml settings. I will add the plugins one by one in case it's one of them and let you know how that goes.

Likely a dead end (?) but here's my config file fwiw:

<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>HelloCordova</name>
    <description>Sample Apache Cordova App</description>
    <author email="dev@cordova.apache.org" href="https://cordova.apache.org">
        Apache Cordova Team
    </author>

<access origin="*" />
    <allow-intent href="*" />
    <allow-navigation href="*" />
    <preference name="AllowInlineMediaPlayback" value="true" />
    <content src="index.html" />
    <preference name="fullscreen" value="true" />
    <preference name="backgroundColor" value="0xff073763" />
    <preference name="StatusBarOverlaysWebView" value="true" />
    <preference name="permissions" value="none" />
    <preference name="phonegap-version" value="3.5.0" />
    <preference name="AllowInlineMediaPlayback" value="true" />
    <preference name="target-device" value="universal" />
    <preference name="prerendered-icon" value="true" />
    <preference name="stay-in-webview" value="false" />
    <preference name="ios-statusbarstyle" value="black-opaque" />
    <preference name="detect-data-types" value="true" />
    <preference name="exit-on-suspend" value="false" />
    <preference name="show-splash-screen-spinner" value="false" />
    <preference name="auto-hide-splash-screen" value="false" />
    <preference name="SplashScreenDelay" value="4000" />
    <preference name="disable-cursor" value="false" />
    <preference name="ITSAppUsesNonExemptEncryption" value="no" />
    <icon src="res/icon.png" />
    <platform name="ios">
        <icon height="57" src="res/icon/ios/icon-57.png" width="57" />
        <icon height="72" src="res/icon/ios/icon-72.png" width="72" />
        <icon height="114" src="res/icon/ios/icon-57-2x.png" width="114" />
        <icon height="144" src="res/icon/ios/icon-72-2x.png" width="144" />
        <gap:splash height="480" src="res/screen/ios/screen-iphone-portrait.png" width="320" />
        <gap:splash height="960" src="res/screen/ios/screen-iphone-portrait-2x.png" width="640" />
        <gap:splash height="1136" src="res/screen/ios/screen-iphone-portrait-568h-2x.png" width="640" />
        <gap:splash height="1024" src="res/screen/ios/screen-ipad-portrait.png" width="768" />
        <gap:splash height="768" src="res/screen/ios/screen-ipad-landscape.png" width="1024" />
        <config-file parent="NSPhotoLibraryUsageDescription" platform="ios" target="*-Info.plist">
            <string>You can upload your profile picture using your Photo Library</string>
        </config-file>
        <config-file parent="NSCameraUsageDescription" platform="ios" target="*-Info.plist">
            <string>You can upload your profile picture using your camera</string>
        </config-file>
        <config-file parent="ITSAppUsesNonExemptEncryption" platform="ios" target="*-Info.plist">
            <string>NO</string>
        </config-file>
        <preference name="AllowUntrustedCerts" value="on" />
        <preference name="InterceptRemoteRequests" value="all" />
        <preference name="NativeXHRLogging" value="full" />        
    </platform>
</widget>
cemerson commented 1 year ago

Just FYI @breautek I added all the same plugins to the hello world app but sadly iPad works fine still. I'll keep trying to find a loose thread to follow and will report back if I find anything.

cemerson commented 1 year ago

FYI after running out of any other ideas I did the old (annoying!) "rm platform ios", "add platform ios" thing and after that it appears iPad is now working (?!). I never found the actual culprit but I'll close this ticket as it looks like something was just screwy and needed a reset of some kind. Thank you again for your earlier reply.