iOS: Using custom instance of VLCLibrary will crash app when VLCMediaPlayer is deallocated
I'm playing around with MobileVLCKit for iOS (pre-built binary from Carthage Repo, MobileVLCKit-3.3.16.3-c3b4cefc-b4c7317a.tar.xz
)
For my specific use case, I need to provide custom options to VLCLibrary to improve RTSP playback (specifically --rtsp-tcp
), but I've found that no matter what I do, the app will crash when the VLCMediaPlayer
is deallocated.
I originally thought I might be able to use a single shared instance for my app, something like
extension VLCLibrary {
static let fastRTSP: VLCLibrary = {
var options = [Any]()
options.append("--rtsp-tcp")
return VLCLibrary(options: options)
}()
}
but this didn't work, so I went to using an instance per media player instead, which still didn't work
var options = [Any]()
options.append("--rtsp-tcp")
let library = VLCLibrary(options: options)
let player = VLCMediaPlayer(library: library)!
loanedPlayers.append(player)
If I just use VLCLibrary.shared()
it seems to work fine, but for my needs, I really, really, really need the --rtsp-tcp
option
This is the crash
MobileVLCKit`-[VLCLibrary dealloc]:
0x100d87f28 <+0>: sub sp, sp, #0x30 ; =0x30
0x100d87f2c <+4>: stp x20, x19, [sp, #0x10]
0x100d87f30 <+8>: stp x29, x30, [sp, #0x20]
0x100d87f34 <+12>: add x29, sp, #0x20 ; =0x20
0x100d87f38 <+16>: mov x19, x0
0x100d87f3c <+20>: ldr x0, [x0, #0x20]
0x100d87f40 <+24>: cbz x0, 0x100d87f50 ; <+40> at VLCLibrary.m:267:9
0x100d87f44 <+28>: bl 0x100d96744 ; libvlc_log_unset
-> 0x100d87f48 <+32>: ldr x0, [x19, #0x20]
0x100d87f4c <+36>: bl 0x100d9586c ; libvlc_release
0x100d87f50 <+40>: ldr x0, [x19, #0x8]
0x100d87f54 <+44>: cbz x0, 0x100d87f5c ; <+52> at VLCLibrary.m:270:1
0x100d87f58 <+48>: bl 0x10224947c ; symbol stub for: fclose
0x100d87f5c <+52>: adrp x8, 7046
0x100d87f60 <+56>: ldr x8, [x8, #0xb68]
0x100d87f64 <+60>: stp x19, x8, [sp]
0x100d87f68 <+64>: adrp x8, 7045
0x100d87f6c <+68>: ldr x1, [x8, #0xc80]
0x100d87f70 <+72>: mov x0, sp
0x100d87f74 <+76>: bl 0x102249b9c ; symbol stub for: objc_msgSendSuper2
0x100d87f78 <+80>: ldp x29, x30, [sp, #0x20]
0x100d87f7c <+84>: ldp x20, x19, [sp, #0x10]
0x100d87f80 <+88>: add sp, sp, #0x30 ; =0x30
0x100d87f84 <+92>: ret
A GitHub project containing my (crazy) experimentation; https://github.com/RustyKnight/TestVLCMore. Sorry the MobileVLCKit framework is not included, to large, but I pulled it form https://download.videolan.org/cocoapods/prod/MobileVLCKit-3.3.16.3-c3b4cefc-b4c7317a.tar.xz (Carthage reference) and unpacked it myself
I'd love to know if there is something "obvious" which I'm doing wrong here, as it's been driving me crazy