Environment
Describe the bug
Runtime error. App installed on iPad Pro 11 (2018), iPad Air, iPhone SE and iPhone X via TestFlight, when forcefully closing the App (via swipe up and swipe out the app to kill it) the App crashes, the Apple log, posted below, suggests either V8 isn't handling this type of App closure, or the main.m . By looking into the main.m source it feels like some sort of handling could potentially go there wrapping the start method. I'm not a C developer otherwise I'd take a stab at it and do a pull request.
Tested it in different conditions and it only crashes if you are in the App and then try to close it.
If you go to the Desktop or another App and then close the App it doesn't show the crash.
It feels like either Apple looses the context and the App still crashes but goes into oblivion, or somehow when the App is put to background goes into some safe condition that allows it to be forcefully shutdown without crashing.
I've wrapped my code in the main function within try catches to ensure it wasn't a crash on our code, but no change.
From the crash report feels like I should be able to do something globally to enable a graceful shutdown.
Outside of this crash the App works as intended in both iOS and Android.
Looking for guidance / ideas on how I can determine the root cause and fix this issue.
Let me know what else could be useful to provide.
I've done:
ns clean
npm install
ns build ios --for-device --release --provision <id>
And here is main part of the crash report from Apple:
Incident Identifier: EE6F69AF-9928-4F1A-8A1F-478C802875AC
Hardware Model: iPad8,1
Process: mobile [631]
Path: /private/var/containers/Bundle/Application/97611BA7-D13D-486D-BE3C-B60FD53C19AF/mobile.app/mobile
Identifier: a.a.a
Version: 1.0.6 (1.0.6)
AppStoreTools: 12A7604b
AppVariant: 1:iPad8,1:14
Beta: YES
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: a.a.a [540]
Date/Time: 2020-10-30 13:12:24.9266 +0000
Launch Time: 2020-10-30 13:12:18.7557 +0000
OS Version: iPhone OS 14.1 (18A8395)
Release Type: User
Baseband Version: n/a
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000101c28128
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [631]
Triggered by Thread: 0
0 NativeScript 0x0000000101c28128 v8::base::OS::Abort() + 24
1 NativeScript 0x0000000101375d14 v8::Isolate::Dispose() + 160
2 NativeScript 0x00000001012b0f38 tns::Runtime::~Runtime() + 164
3 NativeScript 0x00000001011fb73c std::__1::shared_ptr<v8::Persistent<v8::Value, v8::NonCopyablePersistentTraits<v8::Value> > >::~shared_ptr() + 64
4 libsystem_c.dylib 0x0000000198c55328 __cxa_finalize_ranges + 408 (atexit.c:284)
5 libsystem_c.dylib 0x0000000198c55668 exit + 28 (exit.c:81)
6 UIKitCore 0x000000019246aa8c -[UIApplication _terminateWithStatus:] + 504 (UIApplication.m:6534)
7 UIKitCore 0x0000000191af3db0 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 128 (_UISceneLifecycleMultiplexer.m:819)
8 UIKitCore 0x0000000191af3a10 -[_UISceneLifecycleMultiplexer forceExitWithTransitionContext:scene:] + 220 (_UISceneLifecycleMultiplexer.m:457)
9 UIKitCore 0x0000000192460770 -[UIApplication workspaceShouldExit:withTransitionContext:] + 212 (UIApplication.m:3600)
10 FrontBoardServices 0x000000019eb22988 -[FBSUIApplicationWorkspaceShim workspaceShouldExit:withTransitionContext:] + 88 (FBSUIApplicationWorkspace.m:144)
11 FrontBoardServices 0x000000019eb500a4 __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke_2 + 80 (FBSWorkspaceScenesClient.m:312)
12 FrontBoardServices 0x000000019eb34d24 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 240 (FBSWorkspace.m:355)
13 FrontBoardServices 0x000000019eb5003c __63-[FBSWorkspaceScenesClient willTerminateWithTransitionContext:]_block_invoke + 132 (FBSWorkspaceScenesClient.m:309)
14 libdispatch.dylib 0x000000018f73aac8 _dispatch_client_callout + 20 (object.m:559)
15 libdispatch.dylib 0x000000018f73e348 _dispatch_block_invoke_direct + 268 (queue.c:468)
16 FrontBoardServices 0x000000019eb780e0 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 48 (FBSSerialQueue.m:184)
17 FrontBoardServices 0x000000019eb77d88 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 448 (FBSSerialQueue.m:227)
18 FrontBoardServices 0x000000019eb782ac -[FBSSerialQueue _performNextFromRunLoopSource] + 32 (FBSSerialQueue.m:258)
19 CoreFoundation 0x000000018fab981c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1967)
20 CoreFoundation 0x000000018fab9718 __CFRunLoopDoSource0 + 208 (CFRunLoop.c:2011)
21 CoreFoundation 0x000000018fab8a28 __CFRunLoopDoSources0 + 268 (CFRunLoop.c:2048)
22 CoreFoundation 0x000000018fab2d20 __CFRunLoopRun + 824 (CFRunLoop.c:2925)
23 CoreFoundation 0x000000018fab24bc CFRunLoopRunSpecific + 600 (CFRunLoop.c:3242)
24 GraphicsServices 0x00000001a65c4820 GSEventRunModal + 164 (GSEvent.c:2259)
25 UIKitCore 0x000000019245f164 -[UIApplication _run] + 1072 (UIApplication.m:3270)
26 UIKitCore 0x0000000192464840 UIApplicationMain + 168 (UIApplication.m:4739)
27 NativeScript 0x0000000101358044 ffi_call_SYSV + 68
28 NativeScript 0x00000001013564f0 ffi_call_int + 968
29 NativeScript 0x00000001012ca5d0 tns::Interop::CallFunctionInternal(tns::MethodCall&) + 428
30 NativeScript 0x000000010126d160 std::__1::__function::__func<tns::MetadataBuilder::CFunctionCallback(v8::FunctionCallbackInfo<v8::Value> const&)::$_2, std::__1::allocator<tns::MetadataBuilder::CFunctionCallback(v8::FunctionCallba... + 564
31 NativeScript 0x0000000101306e9c tns::Tasks::Drain() + 108
32 NativeScript 0x0000000101300f60 +[NativeScript start:] + 572
33 mobile 0x00000001008c3c4c main + 260 (main.m:58)
34 libdyld.dylib 0x000000018f779e40 start + 4
To Reproduce
Build, submit to App Store, load it via Test Flight, run App, forcefully close it by swiping up and swiping the App out.
Expected behavior
No crash.
Sample project
Will put a sample project together to share as I can't share this one due to IP, but if you have any ideas / suggestions I could take in to identify the cause and fix it would be great.
Additional context
Added the latest xcode params to the build.xcconfig
File: build.xcconfig
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; // For compatibility
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=YES; // For latest
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED=YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING=YES;
CLANG_WARN_COMMA=YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS=YES;
CLANG_WARN_INFINITE_RECURSION=YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION=YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF=YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION=YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS=YES;
CLANG_WARN_STRICT_PROTOTYPES=YES;
CLANG_WARN_SUSPICIOUS_MOVE=YES;
CLANG_WARN_UNREACHABLE_CODE=YES;
DEVELOPMENT_LANGUAGE=en; // Latest
LOCALIZED_RESOURCES_FOLDER_PATH=mobile.app/en.lproj; // Latest
ENABLE_STRICT_OBJC_MSGSEND=YES;
GCC_NO_COMMON_BLOCKS=YES;
IPHONEOS_DEPLOYMENT_TARGET=12.0; // Target 12 upwards, also tried with 14, same issue
Using a top level Podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
File: Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.6</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.6</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiresFullScreen</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<!-- <string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string> -->
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSFaceIDUsageDescription</key>
<string>For easier authentication with our app.</string>
</dict>
</plist>
File: Package.json
{
"name": "name",
"main": "main.js",
"version": "1.0.6",
"description": "Description",
"homepage": "https://a.a.a",
"license": "SEE LICENSE IN LICENSE",
"private": true,
"author": "###@###.###",
"contributors": [
{
"name": "Name",
"email": "###@###.###"
}
],
"bugs": {
"email": "###@###.###"
},
"dependencies": {
"@nativescript/core": "^7.0.13",
"@nativescript/fingerprint-auth": "^7.0.0",
"@nativescript/secure-storage": "^3.0.0",
"@nativescript/theme": "^2.3.3",
"@vue/devtools": "^5.3.3",
"axios": "^0.21.0",
"nativescript-socketio": "^3.3.1",
"nativescript-toasty": "^3.0.0-alpha.2",
"nativescript-vue": "^2.8.1",
"nativescript-vue-devtools": "^1.4.0",
"vuex": "^3.5.1"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@nativescript/android": "7.0.1",
"@nativescript/ios": "7.0.4",
"@nativescript/webpack": "^3.0.8",
"babel-loader": "^8.1.0",
"nativescript-vue-template-compiler": "^2.8.1",
"nativescript-worker-loader": "~0.12.1",
"sass": "^1.28.0",
"vue-loader": "^15.9.4"
}
}
Experiencing the same. Also only for a release build (deployed via TestFlight).
I guess if it was installed from the AppStore you wouldn't even notice because you wouldn't see the TestFlight "your app has crahed, do you want to notify the developer?" notice. But yeah, it's hard to get your app past QA this way.
Experiencing the same. Also only for a release build (deployed via TestFlight).
I guess if it was installed from the AppStore you wouldn't even notice because you wouldn't see the TestFlight "your app has crahed, do you want to notify the developer?" notice. But yeah, it's hard to get your app past QA this way.
Thanks for the confirmation Eddy.
I noticed you have done a few extensions and probably know a bit more about the inner workings of Nativescript, can you think of any suggestions / quick fix around main.m that I can try?
I'm not a C literate, but with some guidance / suggestions I'm sure I can put something together to try and avoid this crash, even if not pretty it will likely allow others to overcome this, at least until the root cause is found and a proper solution is identified.
To help narrowing this down I just created a TestFlight build of the exact same app and dependencies, but only changed @nativescript/ios from 7.0.4 (crash) to 7.0.1 (no crash).
So a change between 7.0.1 and 7.0.4 is causing this "crash on kill" bug. I can easily narrow this down further, so we know if it was caused in either 7.0.2 (rc, there was no official version), 7.0.3, or 7.0.4. I'll try 7.0.3 first.
UPDATE: narrowed it down to some change between @nativescript/ios 7.0.3 and 7.0.4. Luckily there were only 4 days between those releases so that should not be a whole lot of changes.
Thanks for the update, I had a look into the commit logs, but can't really figure out what could be causing it.
Could this be related:
https://github.com/NativeScript/ns-v8ios-runtime/pull/74
A few changes to Isolate seem to have been introduced after 7.0.1 .
Seems I missed this being reported on the ns-v8ios-runtime project, there was a fix, but doesn't seem to fix it, someone else has reiterated that:
https://github.com/NativeScript/ns-v8ios-runtime/issues/51
This was introduced on iOS runtime 7.0.4, works for me on 7.0.3.