Rolamix / cordova-plugin-playlist

🎶 A Cordova plugin for Android and iOS with native support for audio playlists, background support, and lock screen controls 🎶
MIT License
33 stars 33 forks source link

Delete playlist item using track ID causes crash (iOS) #12

Closed robinbanbury closed 5 years ago

robinbanbury commented 6 years ago

Expected Behaviour

Deleting a playlist item (using removeItem) or items (using removeItems) should be possible using the playlist track ID.

Actual Behaviour

Terminates with uncaught exception

screen shot 2018-08-11 at 19 57 04

Reproduce Scenario (including but not limited to)

iOS with Ionic, streaming tracks from SoundCloud using SoundCloud stream URLs

Steps to Reproduce

Following the setup in the examples folder, try using this.cdvAudioPlayer.removeItem({trackId: 'some_track_id'});

Platform and Version

iOS 11.4

Cordova CLI version and cordova platform version

Cordova CLI version 7.1.0

Logs taken while reproducing problem

2018-08-11 19:56:57.644256+0100 GigLicker[6596:2275910] Delete track with playlist ID 34639234-317475-7235730-429476049
2018-08-11 19:56:57.646593+0100 GigLicker[6596:2275910] RmxAudioPlayer.execute=removeItem, 34639234-317475-7235730-429476049, <null>
2018-08-11 19:56:57.646691+0100 GigLicker[6596:2275910] -[NSNull integerValue]: unrecognized selector sent to instance 0x1b5b9b878
2018-08-11 19:56:57.648442+0100 GigLicker[6596:2275910] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull integerValue]: unrecognized selector sent to instance 0x1b5b9b878'
*** First throw call stack:
(0x183566d8c 0x1827205ec 0x183574098 0x18356c5c8 0x18345241c 0x104fd64c8 0x104fd3b90 0x104ff2f84 0x104e9ae54 0x104e9acb8 0x104e9c898 0x193273a2c 0x193210734 0x1932128a4 0x192f79d18 0x1931b920c 0x192f3ccfc 0x192f3f704 0x18ab9e17c 0x18ab9e3ec 0x18350f404 0x18350ec2c 0x18350c79c 0x18342cda8 0x185412020 0x18d44c758 0x104e919a0 0x182ebdfc0)
libc++abi.dylib: terminating with uncaught exception of type NSException

(lldb) frame variable
(RmxAudioPlayer *) self = 0x00000001c02c1d50
(SEL) _cmd = "removeItemWithValues:trackId:"
(NSNull *) trackIndex = 0x00000001b5b9b878 class name = NSNull
(__NSCFString *) trackId = 0x00000001c0872400 @"34639234-317475-7235730-429476049"

Note that the value of trackIndex is NSNull, as opposed to nil. The code in RmxAudioPlayer.m is specifically looking for nil to protect against an illegal conversion on the following line. Since the check is not defeating NSNull objects, the illegal conversion is exposed, causing the error above

codinronan commented 5 years ago

Also :D