[TIMOB-23798] iOS: Ti.UI.Clipboard.clearData() crashes when no MIME type is provided
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-08-23T22:06:53.000+0000 |
Affected Version/s | Release 5.5.0 |
Fix Version/s | Release 5.5.0 |
Components | iOS |
Labels | qe-5.5.0 |
Reporter | Eric Wieber |
Assignee | Hans Knöchel |
Created | 2016-08-22T15:51:52.000+0000 |
Updated | 2016-09-01T22:23:53.000+0000 |
Description
Trying to clear all Pasteboard data with
Ti.UI.Clipboard.clearData()
(with no MIME type provided) crashes the app with the below error.
Either our documentation is incorrect or clearData
should be able to handle 'no arguments'.
*Steps to reproduce issue*
1. Create a new project
2. Add Ti.UI.Clipboard.clearData()
to the code
3. Run the project
*Expected Results*
The Pasteboard data is cleared without issue
*Actual Results*
The app crashes with the below error
*Error*
[ERROR] : The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
[ERROR] : Reason:
[ERROR] : *** -[NSMutableOrderedSet addObject:]: object cannot be nil
[ERROR] : Stack trace:
[ERROR] :
[ERROR] : 0 CoreFoundation 0x0000000109b8f333 __exceptionPreprocess + 147
[ERROR] : 1 libobjc.A.dylib 0x000000010915f21e objc_exception_throw + 48
[ERROR] : 2 CoreFoundation 0x0000000109b26f7c -[NSMutableOrderedSet addObject:] + 172
[ERROR] : 3 Pasteboard 0x000000011f1b948c -[PBItem itemQueue_addRepresentationType:protectAgainstLargeDataSizes:loaderBlock:] + 156
[ERROR] : 4 Pasteboard 0x000000011f1ba0b3 __44-[PBItem addRepresentationType:loaderBlock:]_block_invoke + 51
[ERROR] : 5 libdispatch.dylib 0x000000010aa0b12e _dispatch_client_callout + 8
[ERROR] : 6 libdispatch.dylib 0x000000010a9ef6ec _dispatch_barrier_sync_f_invoke + 119
[ERROR] : 7 Pasteboard 0x000000011f1ba00d -[PBItem addRepresentationType:loaderBlock:] + 237
[ERROR] : 8 UIKit 0x00000001055eeb6f -[_UIConcretePasteboard setData:forPasteboardType:] + 196
[ERROR] : 9 PasteboardCheck 0x0000000102969cfb -[TiUIClipboardProxy clearData:] + 971
[ERROR] : 10 CoreFoundation 0x0000000109b1605c __invoking___ + 140
[ERROR] : 11 CoreFoundation 0x0000000109b15ee1 -[NSInvocation invoke] + 289
[ERROR] : 12 PasteboardCheck 0x000000010277d39d -[KrollMethod call:] + 2045
[ERROR] : 13 PasteboardCheck 0x000000010277bc71 __KrollCallAsFunction_block_invoke + 49
[ERROR] : 14 PasteboardCheck 0x00000001028740fd TiThreadPerformOnMainThread + 77
[ERROR] : 15 PasteboardCheck 0x000000010277b91e KrollCallAsFunction + 702
[ERROR] : 16 PasteboardCheck 0x0000000102b0044d _ZN2TI16JSCallbackObjectINS_20JSDestructibleObjectEE4callEPNS_9ExecStateE + 493
[ERROR] : 17 PasteboardCheck 0x0000000102ba3577 _ZN2TI5LLInt9setUpCallEPNS_9ExecStateEPNS_11InstructionENS_22CodeSpecializationKindENS_7TiValueEPNS_17LLIntCallLinkInfoE + 503
[ERROR] : 18 PasteboardCheck 0x0000000102ba7fad llint_op_call + 148
[ERROR] :
[ERROR] : 2016-08-22 08:42:48.831 PasteboardCheck[20144:8684968] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableOrderedSet addObject:]: object cannot be nil'
[ERROR] : *** First throw call stack:
[ERROR] : (
[ERROR] : 0 CoreFoundation 0x0000000109b8f34b __exceptionPreprocess + 171
[ERROR] : 1 libobjc.A.dylib 0x000000010915f21e objc_exception_throw + 48
[ERROR] : 2 CoreFoundation 0x0000000109b26f7c -[NSMutableOrderedSet addObject:] + 172
[ERROR] : 3 Pasteboard 0x000000011f1b948c -[PBItem itemQueue_addRepresentationType:protectAgainstLargeDataSizes:loaderBlock:] + 156
[ERROR] : 4 Pasteboard 0x000000011f1ba0b3 __44-[PBItem addRepresentationType:loaderBlock:]_block_invoke + 51
[ERROR] : 5 libdispatch.dylib 0x000000010aa0b12e _dispatch_client_callout + 8
[ERROR] : 6 libdispatch.dylib 0x000000010a9ef6ec _dispatch_barrier_sync_f_invoke + 119
[ERROR] : 7 Pasteboard 0x000000011f1ba00d -[PBItem addRepresentationType:loaderBlock:] + 237
[ERROR] : 8 UIKit 0x00000001055eeb6f -[_UIConcretePasteboard setData:forPasteboardType:] + 196
[ERROR] : 9 PasteboardCheck 0x0000000102969cfb -[TiUIClipboardProxy clearData:] + 971
[ERROR] : 10 CoreFoundation 0x0000000109b1605c __invoking___ + 140
[ERROR] : 11 CoreFoundation 0x0000000109b15ee1 -[NSInvocation invoke] + 289
[ERROR] : 12 PasteboardCheck 0x000000010277d39d -[KrollMethod call:] + 2045
[ERROR] : 13 PasteboardCheck 0x000000010277bc71 __KrollCallAsFunction_block_invoke + 49
[ERROR] : 14 PasteboardCheck 0x00000001028740fd TiThreadPerformOnMainThread + 77
[ERROR] : 15 PasteboardCheck 0x000000010277b91e KrollCallAsFunction + 702
[ERROR] : 16 PasteboardCheck 0x0000000102b0044d _ZN2TI16JSCallbackObjectINS_20JSDestructibleObjectEE4callEPNS_9ExecStateE + 493
[ERROR] : 17 PasteboardCheck 0x0000000102ba3577 _ZN2TI5LLInt9setUpCallEPNS_9ExecStateEPNS_11InstructionENS_22CodeSpecializationKindENS_7TiValueEPNS_17LLIntCallLinkInfoE + 503
[ERROR] : 18 PasteboardCheck 0x0000000102ba7fad llint_op_call + 148
[ERROR] : )
[ERROR] : libc++abi.dylib: terminating with uncaught exception of type NSException
[TRACE] : [PasteboardCheck] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableOrderedSet addObject:]: object cannot be nil'
*Notes*
I also get an error when trying to clear a specific data, using a MIME type that I set the data with. For example: I can set data with Ti.UI.Clipboard.setData("colors", "blue");
but get the below error when trying to clear data with Ti.UI.Clipboard.clearData("colors");
[ERROR] : Script Error {
[ERROR] : column = 34;
[ERROR] : line = 12;
[ERROR] : message = "-[__NSArrayM lowercaseString]: unrecognized selector sent to instance 0x608000244710";
[ERROR] : sourceURL = "file:///Users/Eric/Library/Developer/CoreSimulator/Devices/83A39029-8DC3-4231-90FA-C9394BF09F69/data/Containers/Bundle/Application/71392209-38A2-43CD-8D82-B7EC530DBC52/PasteboardCheck.app/alloy/controllers/index.js";
[ERROR] : stack = "[native code]\ndoSet@file:///Users/Eric/Library/Developer/CoreSimulator/Devices/83A39029-8DC3-4231-90FA-C9394BF09F69/data/Containers/Bundle/Application/71392209-38A2-43CD-8D82-B7EC530DBC52/PasteboardCheck.app/alloy/controllers/index.js:12:34";
[ERROR] : }
Just checked. We allow the value to be nil (
ENSURE_STRING_OR_NIL
) but then access it (NSString *mimeType = arg;
afterwards. I would set the mimetype to unknown (like done when the specified mimetype is unrecognized). Is that a proper fix for you?PR: https://github.com/appcelerator/titanium_mobile/pull/8252 PR (5_5_X): https://github.com/appcelerator/titanium_mobile/pull/8291 PR (6_0_X: https://github.com/appcelerator/titanium_mobile/pull/8292 Demo:
Verified fixed, using: MacOS 10.12 (16A239m) Studio 4.7.1.201608190732 Ti SDK 5.5.0.v20160831100821 Appc NPM 4.2.7 Appc CLI 5.5.0-5 Alloy 1.9.1 Xcode 8.0 (8S201h) The app no longer crashes and the specified data is removed, or all data is removed if no type is provided. Tested using the provided example as well as my own test app utilizing
clearData()
.