Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28483] iOS: Crash on startup when launching app on iOS 15

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2021-06-17T10:07:42.000+0000
Affected Version/sRelease 10.0.0
Fix Version/sRelease 10.0.1
ComponentsiOS
Labelsn/a
ReporterEwan Harris
AssigneeGary Mathews
Created2021-06-08T09:26:20.000+0000
Updated2021-06-17T10:07:42.000+0000

Description

Description

When launching an app, it will crash on startup with the below stack:
2021-06-08 10:22:45.286610+0100 Titanium[44498:3323792] -[AppModule JSValueInContext:]: unrecognized selector sent to instance 0x7fa3fb6101a0
2021-06-08 10:22:45.289463+0100 Titanium[44498:3323792] [DEBUG] Loading: /Users/awam/Library/Developer/CoreSimulator/Devices/83B5D759-FF58-4701-BFF2-546F0CBB4466/data/Containers/Bundle/Application/6E7EAA78-DF4C-4513-8003-DC3390E608B1/Titanium.app/ti.kernel.js, Resource: ti_kernel_js
2021-06-08 10:22:45.314020+0100 Titanium[44498:3323792] [ERROR] /ti.kernel.js:1282
	          const realModule = kroll.binding(modName); // Now replace our lazy getter on the property with a value
                                            ^
Error: -[AppModule JSValueInContext:]: unrecognized selector sent to instance 0x7fa3fb6101a0
    at  ([native code])
    at get (/ti.kernel.js:1282:44)
    at  (/ti.kernel.js:1250:27)

    CoreFoundation 0x00007fff203f6fa7 __exceptionPreprocess + 242
    libobjc.A.dylib 0x00007fff2019cbe7 objc_exception_throw + 48
    CoreFoundation 0x00007fff20405b28 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
    CoreFoundation 0x00007fff203fb46b ___forwarding___ + 1412
    CoreFoundation 0x00007fff203fd598 _CF_forwarding_prep_0 + 120
    TitaniumKit 0x000000010b122e34 -[KrollModule binding:] + 628
    CoreFoundation 0x00007fff203fd82c __invoking___ + 140
    CoreFoundation 0x00007fff203fac36 -[NSInvocation invoke] + 305
    JavaScriptCore 0x00007fff324c007b _ZN3JSC24ObjCCallbackFunctionImpl4callEP9JSContextP13OpaqueJSValuemPKPKS3_PS6_ + 427
    JavaScriptCore 0x00007fff324bf980 _ZN3JSCL34objCCallbackFunctionCallAsFunctionEPK15OpaqueJSContextP13OpaqueJSValueS4_mPKPKS3_PS6_ + 256
    JavaScriptCore 0x00007fff324c314a _ZN3JSC19APICallbackFunction8callImplINS_20ObjCCallbackFunctionEEExPNS_14JSGlobalObjectEPNS_9CallFrameE + 570
    ??? 0x000025a64e001027 0x0 + 41396203425831
    JavaScriptCore 0x00007fff32445a03 llint_entry + 110156
    JavaScriptCore 0x00007fff3242a9b6 vmEntryToJavaScript + 216
    JavaScriptCore 0x00007fff32b3593c _ZN3JSC11Interpreter11executeCallEPNS_14JSGlobalObjectEPNS_8JSObjectERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 540
    JavaScriptCore 0x00007fff32e20aab _ZN3JSC10callGetterEPNS_14JSGlobalObjectENS_7JSValueES2_ + 203
    JavaScriptCore 0x00007fff32c43196 _ZN3JSC5LLIntL19performLLIntGetByIDEPKNS_11InstructionEPNS_9CodeBlockEPNS_14JSGlobalObjectENS_7JSValueERKNS_10IdentifierERNS_19GetByIdModeMetadataE + 1814
    JavaScriptCore 0x00007fff32c429db llint_slow_path_get_by_id + 347
    JavaScriptCore 0x00007fff32434150 llint_entry + 38297
    JavaScriptCore 0x00007fff3242a9b6 vmEntryToJavaScript + 216
2021-06-08 10:22:45.329160+0100 Titanium[44498:3323792] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppModule JSValueInContext:]: unrecognized selector sent to instance 0x7fa3fb6101a0'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff203f6fa7 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007fff2019cbe7 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff20405b28 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
	3   CoreFoundation                      0x00007fff203fb46b ___forwarding___ + 1412
	4   CoreFoundation                      0x00007fff203fd598 _CF_forwarding_prep_0 + 120
	5   TitaniumKit                         0x000000010b122e34 -[KrollModule binding:] + 628
	6   CoreFoundation                      0x00007fff203fd82c __invoking___ + 140
	7   CoreFoundation                      0x00007fff203fac36 -[NSInvocation invoke] + 305
	8   JavaScriptCore                      0x00007fff324c007b _ZN3JSC24ObjCCallbackFunctionImpl4callEP9JSContextP13OpaqueJSValuemPKPKS3_PS6_ + 427
	9   JavaScriptCore                      0x00007fff324bf980 _ZN3JSCL34objCCallbackFunctionCallAsFunctionEPK15OpaqueJSContextP13OpaqueJSValueS4_mPKPKS3_PS6_ + 256
	10  JavaScriptCore                      0x00007fff324c314a _ZN3JSC19APICallbackFunction8callImplINS_20ObjCCallbackFunctionEEExPNS_14JSGlobalObjectEPNS_9CallFrameE + 570
	11  ???                                 0x000025a64e001027 0x0 + 41396203425831
	12  JavaScriptCore                      0x00007fff32445a03 llint_entry + 110156
	13  JavaScriptCore                      0x00007fff3242a9b6 vmEntryToJavaScript + 216
	14  JavaScriptCore                      0x00007fff32b3593c _ZN3JSC11Interpreter11executeCallEPNS_14JSGlobalObjectEPNS_8JSObjectERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 540
	15  JavaScriptCore                      0x00007fff32e20aab _ZN3JSC10callGetterEPNS_14JSGlobalObjectENS_7JSValueES2_ + 203
	16  JavaScriptCore                      0x00007fff32c43196 _ZN3JSC5LLIntL19performLLIntGetByIDEPKNS_11InstructionEPNS_9CodeBlockEPNS_14JSGlobalObjectENS_7JSValueERKNS_10IdentifierERNS_19GetByIdModeMetadataE + 1814
	17  JavaScriptCore                      0x00007fff32c429db llint_slow_path_get_by_id + 347
	18  JavaScriptCore                      0x00007fff32434150 llint_entry + 38297
	19  JavaScriptCore                      0x00007fff3242a9b6 vmEntryToJavaScript + 216
	20  JavaScriptCore                      0x00007fff32b3593c _ZN3JSC11Interpreter11executeCallEPNS_14JSGlobalObjectEPNS_8JSObjectERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 540
	21  JavaScriptCore                      0x00007fff32dad474 _ZN3JSC12profiledCallEPNS_14JSGlobalObjectENS_15ProfilingReasonENS_7JSValueERKNS_8CallDataES3_RKNS_7ArgListE + 164
	22  JavaScriptCore                      0x00007fff324e0a8e JSObjectCallAsFunction + 798
	23  JavaScriptCore                      0x00007fff32473047 -[JSValue invokeMethod:withArguments:] + 663
	24  TitaniumKit                         0x000000010b14c547 -[KrollBridge evalFileOnThread:context:] + 791
	25  TitaniumKit                         0x000000010b1a4797 -[KrollInvocation invoke:] + 87
	26  TitaniumKit                         0x000000010b1a55b4 -[KrollContext invoke:] + 148
	27  TitaniumKit                         0x000000010b1a5879 -[KrollContext invokeOnThread:method:withObject:callback:selector:] + 121
	28  TitaniumKit                         0x000000010b14c643 -[KrollBridge evalFile:callback:selector:] + 83
	29  TitaniumKit                         0x000000010b14d620 -[KrollBridge didStartNewContext:] + 3088
	30  TitaniumKit                         0x000000010b1a5f6b -[KrollContext main] + 1403
	31  TitaniumKit                         0x000000010b1a5474 __21-[KrollContext start]_block_invoke + 36
	32  libdispatch.dylib                   0x000000010ae3c5e0 _dispatch_call_block_and_release + 12
	33  libdispatch.dylib                   0x000000010ae3d7eb _dispatch_client_callout + 8
	34  libdispatch.dylib                   0x000000010ae4bfa1 _dispatch_main_queue_callback_4CF + 1195
	35  CoreFoundation                      0x00007fff20363614 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	36  CoreFoundation                      0x00007fff2035de60 __CFRunLoopRun + 2772
	37  CoreFoundation                      0x00007fff2035cea9 CFRunLoopRunSpecific + 567
	38  GraphicsServices                    0x00007fff2c951cd3 GSEventRunModal + 139
	39  UIKitCore                           0x00007fff24f2f72a -[UIApplication _run] + 915
	40  UIKitCore                           0x00007fff24f34192 UIApplicationMain + 101
	41  Titanium                            0x000000010a898dd6 main + 806
	42  dyld                                0x000000010acbce1e start_sim + 10
	43  ???                                 0x0000000000000001 0x0 + 1
	44  ???                                 0x0000000000000001 0x0 + 1
)
After adding some debug logs, it appears that the App and UI modules are now entering the if statement [here](https://github.com/appcelerator/titanium_mobile/blob/9b319e97b0f2ae7a1bc3e43e902f7c2779103b97/iphone/TitaniumKit/TitaniumKit/Sources/API/KrollModule.m#L82-L84) during loading rather than going the the loading below. Adding code that ignores the App/UI modules in the ObjcProxy loading and forces them to the KrollObject loading allows the app to load succesfully

Steps to reproduce

1. Run an app on an iOS 15 simulator

Actual

App crashes with above error

Expected

App should load ok

Comments

  1. Ewan Harris 2021-06-08

    This might be an iOS 15 bug? The following code prints and the class says 1 for all module instances which seems sus, iOS 13.4 prints and the class says 0
       BOOL isClass = [module isKindOfClass:[NSString class]];
       NSLog(@"[DEBUG] and the class says %d", isClass);
       
  2. Ewan Harris 2021-06-08

    Chatting with [~jvennemann] and we found that isKindOfClass works ok for basic usage in a simple native project so this might not be a simple iOS bug (or an iOS bug at all)
  3. Gary Mathews 2021-06-08

    master: https://github.com/appcelerator/titanium_mobile/pull/12872
  4. Ewan Harris 2021-06-15

    Just noting that this issue only occurs when using SDK 10+, an application built using SDK 9 starts up no problem
  5. Ewan Harris 2021-06-16

    [~amukherjee] I think it would be good for this to be placed into 10.0.1, is that ok? Currently any application built with SDK 10 crashes on iOS 15. So if we get the fix in asap it allows time for folks to update and release ahead of iOS 15 SDK 9.X is not impacted by this as the changes were new in SDK 10
  6. Ewan Harris 2021-06-16

    master PR merged
  7. Ewan Harris 2021-06-17

    backport merged

JSON Source