ios-jsc icon indicating copy to clipboard operation
ios-jsc copied to clipboard

App crashes on iOS if system alert pops up while loading frameworks

Open enchev opened this issue 9 years ago • 5 comments

From @speigg on February 11, 2016 17:4

May be a little difficult to reproduce due to the nature of the bug.

If a system alert (such as a calendar event alert, or any other number of system alerts, like storage space warning) pops up while a nativescript app has not finished loading (frameworks still loading), the app crashes. This happened while I was attached to the app via XCode. Here is a stack trace (hopefully it's useful):

* thread #1: tid = 0xc26b7, 0x0000000180b52214 libobjc.A.dylib`cache_erase_nolock + 36, queue = 'com.apple.main-thread', stop reason = signal SIGKILL
    frame #0: 0x0000000180b52214 libobjc.A.dylib`cache_erase_nolock + 36
    frame #1: 0x0000000180b5f0fc libobjc.A.dylib`___ZL35foreach_realized_class_and_subclassP10objc_classU13block_pointerFvS0_E_block_invoke + 20
    frame #2: 0x0000000180b56c6c libobjc.A.dylib`flushCaches(objc_class*) + 336
    frame #3: 0x0000000180b5e964 libobjc.A.dylib`attachCategories(objc_class*, locstamped_category_list_t*, bool) + 868
    frame #4: 0x0000000180b58e4c libobjc.A.dylib`remethodizeClass(objc_class*) + 136
    frame #5: 0x0000000180b5819c libobjc.A.dylib`_read_images + 2596
    frame #6: 0x0000000180b64a14 libobjc.A.dylib`map_images_nolock + 812
    frame #7: 0x0000000180b56d64 libobjc.A.dylib`map_2_images + 56
    frame #8: 0x00000001200e0828 dyld`dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) + 1144
    frame #9: 0x00000001200eb44c dyld`ImageLoader::link(ImageLoader::LinkContext const&, bool, bool, bool, ImageLoader::RPathChain const&) + 304
    frame #10: 0x00000001200e0c94 dyld`dyld::link(ImageLoader*, bool, bool, ImageLoader::RPathChain const&) + 176
    frame #11: 0x00000001200e67bc dyld`dlopen + 760
    frame #12: 0x0000000180f696b0 libdyld.dylib`dlopen + 76
    frame #13: 0x000000018143146c CoreFoundation`_CFBundleDlfcnLoadBundle + 144
    frame #14: 0x0000000181431248 CoreFoundation`_CFBundleLoadExecutableAndReturnError + 356
    frame #15: 0x000000010012d7c8 myapp`NativeScript::CFBundleSymbolResolver::load() + 32
    frame #16: 0x000000010012d570 myapp`NativeScript::SymbolLoader::ensureModule(Metadata::ModuleMeta const*) + 28
    frame #17: 0x00000001001273f4 myapp`NativeScript::ObjCPrototype::materializeProperties(JSC::VM&, NativeScript::GlobalObject*) + 228
    frame #18: 0x0000000100134484 myapp`NativeScript::TypeFactory::getObjCNativeConstructor(NativeScript::GlobalObject*, WTF::String const&) + 3472
    frame #19: 0x0000000100131c04 myapp`NativeScript::TypeFactory::parseType(NativeScript::GlobalObject*, Metadata::TypeEncoding const*&) + 604
    frame #20: 0x00000001001227f8 myapp`NativeScript::ObjCMethodCall::finishCreation(JSC::VM&, NativeScript::GlobalObject*, Metadata::MethodMeta const*) + 200
    frame #21: 0x0000000100127730 myapp`NativeScript::ObjCPrototype::materializeProperties(JSC::VM&, NativeScript::GlobalObject*) + 1056
    frame #22: 0x0000000100134484 myapp`NativeScript::TypeFactory::getObjCNativeConstructor(NativeScript::GlobalObject*, WTF::String const&) + 3472
    frame #23: 0x0000000100131c04 myapp`NativeScript::TypeFactory::parseType(NativeScript::GlobalObject*, Metadata::TypeEncoding const*&) + 604
    frame #24: 0x00000001001227f8 myapp`NativeScript::ObjCMethodCall::finishCreation(JSC::VM&, NativeScript::GlobalObject*, Metadata::MethodMeta const*) + 200
    frame #25: 0x0000000100127730 myapp`NativeScript::ObjCPrototype::materializeProperties(JSC::VM&, NativeScript::GlobalObject*) + 1056
    frame #26: 0x0000000100134484 myapp`NativeScript::TypeFactory::getObjCNativeConstructor(NativeScript::GlobalObject*, WTF::String const&) + 3472
    frame #27: 0x0000000100131c04 myapp`NativeScript::TypeFactory::parseType(NativeScript::GlobalObject*, Metadata::TypeEncoding const*&) + 604
    frame #28: 0x00000001001227f8 myapp`NativeScript::ObjCMethodCall::finishCreation(JSC::VM&, NativeScript::GlobalObject*, Metadata::MethodMeta const*) + 200
    frame #29: 0x0000000100127730 myapp`NativeScript::ObjCPrototype::materializeProperties(JSC::VM&, NativeScript::GlobalObject*) + 1056
    frame #30: 0x0000000100134484 myapp`NativeScript::TypeFactory::getObjCNativeConstructor(NativeScript::GlobalObject*, WTF::String const&) + 3472
    frame #31: 0x0000000100133838 myapp`NativeScript::TypeFactory::getObjCNativeConstructor(NativeScript::GlobalObject*, WTF::String const&) + 324
    frame #32: 0x0000000100131c04 myapp`NativeScript::TypeFactory::parseType(NativeScript::GlobalObject*, Metadata::TypeEncoding const*&) + 604
    frame #33: 0x00000001001227f8 myapp`NativeScript::ObjCMethodCall::finishCreation(JSC::VM&, NativeScript::GlobalObject*, Metadata::MethodMeta const*) + 200
    frame #34: 0x0000000100127730 myapp`NativeScript::ObjCPrototype::materializeProperties(JSC::VM&, NativeScript::GlobalObject*) + 1056
    frame #35: 0x0000000100134484 myapp`NativeScript::TypeFactory::getObjCNativeConstructor(NativeScript::GlobalObject*, WTF::String const&) + 3472
    frame #36: 0x0000000100131c04 myapp`NativeScript::TypeFactory::parseType(NativeScript::GlobalObject*, Metadata::TypeEncoding const*&) + 604
    frame #37: 0x0000000100131dd0 myapp`NativeScript::TypeFactory::parseTypes(NativeScript::GlobalObject*, Metadata::TypeEncoding const*&, int) + 76
    frame #38: 0x00000001001065cc myapp`NativeScript::getCompilerEncoding(JSC::JSGlobalObject*, Metadata::MethodMeta const*) + 164
    frame #39: 0x000000010011bbbc myapp`NativeScript::addMethodToClass(JSC::ExecState*, objc_class*, JSC::JSCell*, Metadata::MethodMeta const*) + 92
    frame #40: 0x000000010011d9a4 myapp`NativeScript::ObjCClassBuilder::addInstanceMembers(JSC::ExecState*, JSC::JSObject*, JSC::JSValue) + 2392
    frame #41: 0x0000000100122498 myapp`___ZN12NativeScript28ObjCTypeScriptExtendFunctionEPN3JSC9ExecStateE_block_invoke + 424
    frame #42: 0x0000000180b54fc8 libobjc.A.dylib`_class_initialize + 800
    frame #43: 0x0000000180b5b8f8 libobjc.A.dylib`lookUpImpOrForward + 184
    frame #44: 0x0000000180b65db8 libobjc.A.dylib`_objc_msgSend_uncached_impcache + 56
    frame #45: 0x0000000180b6e778 libobjc.A.dylib`+[NSObject new] + 56
    frame #46: 0x0000000100644044 myapp`ffi_call_SYSV + 68
    frame #47: 0x0000000100640b1c myapp`ffi_call_int + 1136
    frame #48: 0x00000001006406a0 myapp`ffi_call + 56
    frame #49: 0x00000001000fc2cc myapp`NativeScript::FFICall::call(JSC::ExecState*) + 224
    frame #50: 0x00000001003ebf98 myapp`JSC::LLInt::setUpCall(JSC::ExecState*, JSC::Instruction*, JSC::CodeSpecializationKind, JSC::JSValue, JSC::LLIntCallLinkInfo*) + 480
    frame #51: 0x00000001003f2428 myapp`llint_entry + 23256
    frame #52: 0x00000001003f2438 myapp`llint_entry + 23272
    frame #53: 0x00000001003f23d4 myapp`llint_entry + 23172
    frame #54: 0x00000001003f23d4 myapp`llint_entry + 23172
    frame #55: 0x00000001003f2438 myapp`llint_entry + 23272
    frame #56: 0x00000001003f2438 myapp`llint_entry + 23272
    frame #57: 0x00000001003f23d4 myapp`llint_entry + 23172
    frame #58: 0x00000001003f23d4 myapp`llint_entry + 23172
    frame #59: 0x00000001003f2438 myapp`llint_entry + 23272
    frame #60: 0x00000001003f2438 myapp`llint_entry + 23272
    frame #61: 0x00000001003f23d4 myapp`llint_entry + 23172
    frame #62: 0x00000001003f23d4 myapp`llint_entry + 23172
    frame #63: 0x00000001003f2438 myapp`llint_entry + 23272
    frame #64: 0x00000001003f2438 myapp`llint_entry + 23272
    frame #65: 0x00000001003f23d4 myapp`llint_entry + 23172
    frame #66: 0x00000001003f23d4 myapp`llint_entry + 23172
    frame #67: 0x00000001003f2438 myapp`llint_entry + 23272
    frame #68: 0x00000001003f2438 myapp`llint_entry + 23272
    frame #69: 0x00000001003f23d4 myapp`llint_entry + 23172
    frame #70: 0x00000001003f23d4 myapp`llint_entry + 23172
    frame #71: 0x00000001003f2438 myapp`llint_entry + 23272
    frame #72: 0x00000001003f2438 myapp`llint_entry + 23272
    frame #73: 0x00000001003f23d4 myapp`llint_entry + 23172
    frame #74: 0x00000001003f2438 myapp`llint_entry + 23272
    frame #75: 0x00000001003f2438 myapp`llint_entry + 23272
    frame #76: 0x00000001003f2438 myapp`llint_entry + 23272
    frame #77: 0x00000001003f2438 myapp`llint_entry + 23272
    frame #78: 0x00000001003ec788 myapp`vmEntryToJavaScript + 264
    frame #79: 0x00000001003987d0 myapp`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
    frame #80: 0x000000010037d358 myapp`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 392
    frame #81: 0x00000001004be944 myapp`JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&, WTF::NakedPtr<JSC::Exception>&) + 84
    frame #82: 0x000000010012ee30 myapp`-[TNSRuntime executeModule:] + 1332
  * frame #83: 0x00000001000f83e0 myapp`main(argc=1, argv=0x000000016fd0ba80) + 992 at main.m:47
    frame #84: 0x0000000180f6a8b8 libdyld.dylib`start + 4

And the console log output (as far as it got before it crashed):

NativeScript loaded bundle file:///System/Library/Frameworks/UIKit.framework
NativeScript loaded bundle file:///System/Library/Frameworks/Foundation.framework
NativeScript loaded bundle file:///System/Library/Frameworks/CoreImage.framework
NativeScript loaded bundle file:///System/Library/Frameworks/QuartzCore.framework
NativeScript loaded bundle file:///System/Library/Frameworks/iAd.framework

Copied from original issue: NativeScript/NativeScript#1541

enchev avatar Feb 12 '16 07:02 enchev

Fix for this? Having this issue on production app. App asks to allow notifications on load- works in development version but crashes in production.

mschahczinski avatar Nov 03 '16 19:11 mschahczinski

Hey, @mschahczinski, can you provide the crash log of the app. Also, can you give us some more details about the crash so we can reproduce it on our side.

jasssonpet avatar Nov 04 '16 11:11 jasssonpet

@jasssonpet - Thanks for the response... Please see attached crash log.

Cliff notes: I was having an issue getting a production version of my app to run. After some time spent pulling my hair out, I could not get the issue resolved. My app would run fine when running in debug, but as soon as I would publish the app and install, it would never fully launch (crashed shortly after splashscreen would appear).

So I thought, maybe it's something with my project. I created a minimal app- tns create fireTest --ng, added the iOS platform and the plugin that I need in my actual app. Again, app runs fine debugging- production version crashes in the same place. Somehow I stumbled upon this issue with the iOS runtime. My curiosity lead me to realize that the plugin that I am using nativescript-plugin-firebase alerts immediately to allow notifications on my device when the app is run.

I am hoping that this issue is what is causing my app crashes, because thanks to all of the time that I have spent debugging the plugin code and my own code, this is the only thing that makes sense. I will also note that it is not a provisioning profile issue (as far as I'm concerned), because if I never initialize the plugin code, the app works fine as a production build- common theme.... It never pops up an alert on launch.

CrashLog.txt

mschahczinski avatar Nov 04 '16 15:11 mschahczinski

I've created a new app and followed the guide described in nativescript-plugin-firebase but I couldn't reproduce the issue. I will try it later with a different permission.

From the crash log it seems that the application is dying with a JavaScript error (0xDEADDEAD). You can try getting this line out of the #if DEBUG scope: https://github.com/NativeScript/ios-runtime/blob/8021581c64c7cf73fdfde32175eca85d62ac8865/build/project-template/internal/main.m#L34 and watch the system logs for more output.

P.S. Also, when you say that the app is crashing in production, do you mean a local release build or a download from the App Store.

jasssonpet avatar Nov 07 '16 16:11 jasssonpet

@jasssonpet - If you are trying to do a local release build and running it, it works fine when I do that as well. I am having the issue when I publish the project- tns publish ios OR by archive in xCode using the iOS workspace. This is the only time the application crashes- on those builds.

mschahczinski avatar Nov 07 '16 16:11 mschahczinski