[TIMOB-28415] iOS: KrollBridge no longer exposes "modules" method as of 10.0.0
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2021-11-02T18:59:41.000+0000 |
Affected Version/s | Release 10.0.0 |
Fix Version/s | n/a |
Components | iOS |
Labels | crash, ios, modules |
Reporter | Hans Knöchel |
Assignee | Joshua Quick |
Created | 2021-04-11T10:01:07.000+0000 |
Updated | 2021-11-02T18:59:41.000+0000 |
Description
This took us days to track down: There are crashes related to setters in modules built with SDK 9.x when running in an app with SDK 10. The following selector has been used (accessed via
via.canDrag = true
):
- (void)setCanDrag:(NSNumber *)value
The full method can be found [here](https://github.com/hansemannn/titanium-drag-and-drop/blob/master/ios/Classes/TiUIViewProxy%2BDragAndDrop.m#L15-L29).
The crash is:
[DEBUG] -[__NSCFString count]: unrecognized selector sent to instance 0x7f83dc335000
[DEBUG] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString count]: unrecognized selector sent to instance 0x7f83dc335000'
[DEBUG] *** First throw call stack:
[DEBUG] (
[DEBUG] 0 CoreFoundation 0x00007fff20421af6 __exceptionPreprocess + 242
[DEBUG] 1 libobjc.A.dylib 0x00007fff20177e78 objc_exception_throw + 48
[DEBUG] 2 CoreFoundation 0x00007fff204306f7 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
[DEBUG] 3 CoreFoundation 0x00007fff20426036 ___forwarding___ + 1489
[DEBUG] 4 CoreFoundation 0x00007fff20428068 _CF_forwarding_prep_0 + 120
[DEBUG] 5 TitaniumKit 0x00000001090e19f5 -[TiScriptError formattedNativeStack] + 133
[DEBUG] 6 TitaniumKit 0x00000001090e18fb -[TiScriptError description] + 1127
[DEBUG] 7 Foundation 0x00007fff2084c37a _NSDescriptionWithLocaleFunc + 82
[DEBUG] 8 CoreFoundation 0x00007fff203bae0d __CFStringAppendFormatCore + 12102
[DEBUG] 9 CoreFoundation 0x00007fff203bc8a1 _CFStringCreateWithFormatAndArgumentsReturningMetadata + 145
[DEBUG] 10 CoreFoundation 0x00007fff203bc80a _CFStringCreateWithFormatAndArgumentsAux2 + 20
[DEBUG] 11 TitaniumKit 0x00000001090a3f3d TiLogMessage + 175
[DEBUG] 12 TitaniumKit 0x00000001090e0eb0 -[TiExceptionHandler reportScriptError:] + 74
[DEBUG] 13 TitaniumKit 0x00000001090cdd9e TiBindingEventProcess + 731
[DEBUG] 14 TitaniumKit 0x00000001090ef223 -[KrollContext invoke:] + 109
[DEBUG] 15 TitaniumKit 0x00000001090ef296 -[KrollContext enqueue:] + 93
[DEBUG] 16 TitaniumKit 0x00000001090f6640 TiBindingRunLoopEnqueue + 77
[DEBUG] 17 TitaniumKit 0x00000001090f4d45 -[TiProxy fireEvent:withObject:propagate:reportSuccess:errorCode:message:] + 187
[DEBUG] 18 TitaniumKit 0x00000001090d5b08 -[TiViewProxy fireEvent:withObject:propagate:reportSuccess:errorCode:message:] + 224
[DEBUG] 19 TitaniumKit 0x00000001090f4b3b -[TiProxy fireEvent:withObject:propagate:] + 76
[DEBUG] 20 libdispatch.dylib 0x00007fff2010532f _dispatch_call_block_and_release + 12
[DEBUG] 21 libdispatch.dylib 0x00007fff20106508 _dispatch_client_callout + 8
[DEBUG] 22 libdispatch.dylib 0x00007fff20112ff7 _dispatch_main_queue_callback_4CF + 1045
[DEBUG] 23 CoreFoundation 0x00007fff2038fdbb __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
[DEBUG] 24 CoreFoundation 0x00007fff2038a63e __CFRunLoopRun + 2685
[DEBUG] 25 CoreFoundation 0x00007fff203896d6 CFRunLoopRunSpecific + 567
[DEBUG] 26 GraphicsServices 0x00007fff2c257db3 GSEventRunModal + 139
[DEBUG] 27 UIKitCore 0x00007fff24696cf7 -[UIApplication _run] + 912
[DEBUG] 28 UIKitCore 0x00007fff2469bba8 UIApplicationMain + 101
[DEBUG] 29 Lambus 0x0000000106d8693b main + 1115
[DEBUG] 30 libdyld.dylib 0x00007fff2025a3e9 start + 1
[DEBUG] )
The same works fine with SDK 9.3.2.GA and can be reproduced in our project shared with the team. I created a workaround in my module which can be seen [here](https://github.com/hansemannn/titanium-drag-and-drop/pull/4)
Can someone please address this? It's causing hundrets of crashes and it could be any module (along with the one already fixed)!
I have to calm a bit btw: It's still a prerelease :-)
I'm not 100% certain the issue here is with the setter implementations. The underlying stack trace is obscured by our error handling tossing its own error while trying to handle it. I created a local branch and cherry-picked [~jquick]'s fix from https://github.com/appcelerator/titanium_mobile/pull/12721, then created an app, pasted in your module's example code into app.js, and launched its with the v1.0.0 zip on the releases page and a local build of SDK from master (10.1.0). This is what it threw:
I think your code to try and access the shared singleton of the module instance is what's causing the issue (specifically https://github.com/hansemannn/titanium-drag-and-drop/blob/master/ios/Classes/TiDraganddropModule.m#L90-L94 ) - and it's to be expected, because KrollBridge does not have a
modules
property anymore. You were relying on some real internal knowledge there. Can you modify the module's init method to assign to some static singleton variable that theinstance
method could then return?I did [this pull request](https://github.com/hansemannn/titanium-drag-and-drop/pull/4/files) to workaround the issues, in detail: - The "setCanDrag" and "setCanDrop" were property accessors (for "view.canDrag = true" and "view.canDrop"). If I leave it as-is, the methods could not be called - I'm not 100 % sure anymore if it was the setter in general or the underlaying "ENSURE_UI_THREAD". Therefore the PR did a bit more: - Move from setter to "real" method - Move from ENSURE_UI_THREAD to "TiThreadPerformOnMainThread" (incl. proper weak-selfs) - Move from
\[TiApp.app.krollBridge valueForKey:@"modules"\]
to\[TiApp.app valueForKey:@"modules"\]
which (I hope) stays as-is for a while. I noticed that the naming of the module keys also changed from the identifier to the native class name ("ti.draganddrop" to "TiDraganddropModule") So to conclude, maybe I was testing with an old build for the setters, but I was pretty sure they haven't been called at all. Together with TIMOB-28419, I think we're running stable right now. So we could close this ticket for now and keep an eye on module compatibility.Testing with v1.0.0 against master branch, I generated this patch PR: https://github.com/appcelerator/titanium_mobile/pull/12724 Those changes seem to be enough for the example app to work. (Though I should note that the drop event listener being
console.warn
unbound did trigger an error. I had to change it to add the event listener asconsole.warn.bind(console)
) So I don't think the setters are broken at all here.https://github.com/appcelerator/titanium_mobile/pull/12724
The following PR replaces the above PR. It adds review feedback and solves conflicts. PR (master): https://github.com/appcelerator/titanium_mobile/pull/13161
Closing as "invalid". We agreed that this is an undocumented API that should not be depended on.