Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9155] iOS: queryMusicLibrary crashes with undefined value in predicate

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionNot Our Bug
Resolution Date2016-11-02T12:21:42.000+0000
Affected Version/sRelease 2.0.1
Fix Version/sn/a
ComponentsiOS
Labelsapi
ReporterArthur Evans
AssigneeEric Merriman
Created2012-05-16T14:18:49.000+0000
Updated2017-03-14T22:12:34.000+0000

Description

I had an error in my code that was returning an undefined value instead of the text value I'd entered into my text field. This caused queryMusicLibrary to crash with code like the following:
items = Ti.Media.queryMusicLibrary({
	title: { value: undefined, exact: false }
});
It seems like we should handle this better--at least catching the condition and throwing a more coherent exception, instead of with a bit iOS stack trace:
May 16 14:07:27 unknown MusicLibraryTest[776] <Error>: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'invalid value (nil) for property item_extra.title.'
	*** First throw call stack:
	(0x37d528bf 0x318381e5 0x37d527b9 0x31c513b3 0x349dfb91 0x349e7f05 0x314e0245 0x314df8a3 0x314df6b3 0x314da85d 0x314dc277 0x314da815 0x314d824b 0x37a0dd55 0x37a10897 0x361751cf 0x361750a4)
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 1   libobjc.A.dylib                     0x318381e5 objc_exception_throw + 32
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 2   CoreFoundation                      0x37d527b9 +[NSException raise:format:] + 0
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 3   Foundation                          0x31c513b3 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 90
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 4   MusicLibrary                        0x349dfb91 -[ML3ComparisonPredicate initWithProperty:value:comparison:caseInsensitive:transformFunction:treatNullAsBlank:] + 176
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 5   MusicLibrary                        0x349e7f05 +[ML3ComparisonPredicate predicateWithProperty:value:comparison:caseInsensitive:] + 80
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 6   MediaPlayer                         0x314e0245 -[MPMediaPropertyPredicate(ML3Additions) _ML3PredicateForML3EntityProperty:] + 276
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 7   MediaPlayer                         0x314df8a3 -[MPMediaQueryCriteria(ML3Additions) ML3ItemsQueryInLibrary:orderingProperties:nameBlankProperty:] + 490
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 8   MediaPlayer                         0x314df6b3 -[MPMediaQueryCriteria(ML3Additions) ML3ItemsQueryInLibrary:] + 86
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 9   MediaPlayer                         0x314da85d __60-[MPMediaLibraryDataProviderML3 loadItemsUsingFetchRequest:]_block_invoke_0 + 68
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 10  MediaPlayer                         0x314dc277 -[MPMediaLibraryDataProviderML3 performBackgroundTaskWithBlock:] + 238
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 11  MediaPlayer                         0x314da815 -[MPMediaLibraryDataProviderML3 loadItemsUsingFetchRequest:] + 80
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 12  MediaPlayer                         0x314d824b __56-[MPMediaEntityStreamArray _onQueueStartLoadingEntities]_block_invoke_0 + 42
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 13  libdispatch.dylib                   0x37a0dd55 _dispatch_call_block_and_release + 12
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 14  libdispatch.dylib                   0x37a10897 _dispatch_worker_thread2 + 258
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 15  libsystem_c.dylib                   0x361751cf _pthread_wqthread + 294
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: 16  libsystem_c.dylib                   0x361750a4 start_wqthread + 8
May 16 14:07:27 unknown UIKitApplication:com.appcelerator.musiclibtest[0xb3ee][776] <Notice>: terminate called throwing an exception
May 16 14:07:27 unknown ReportCrash[781] <Notice>: Formulating crash report for process MusicLibraryTest[776]
May 16 14:07:27 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.appcelerator.musiclibtest[0xb3ee]) Job appears to have crashed: Abort trap: 6
May 16 14:07:27 unknown SpringBoard[15] <Warning>: Application 'MusicLibraryTest' exited abnormally with signal 6: Abort trap:

Comments

  1. Hans Knöchel 2016-11-02

    Resolving as "Not Our Bug", since the [docs](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media-method-queryMusicLibrary) clearly say which parameters (an Array of valid Ti.Media.Item) are expected by the method. Please always validate your parameter before, thx!
  2. Lee Morris 2017-03-14

    Closing ticket as the issue is not our bug.

JSON Source