MobileVLCKit interferes with SwiftUI property bindings
I encounter this in my project, so I created a stripped-down example to demonstrate the issue: https://github.com/ken107/vlckit/commits/master (see examples/iOS/SwiftUISimplePlayback)
The example shows a video player and a Play/Stop button. Clicking Play will set the
url property to a sample video, clicking Stop will reset it to
nil. I use SwiftUI's property bindings to hide the Play button and show the Stop button if
url != nil. The
url is also passed to the VideoView for playback. The VideoView is a UIViewRepresentable wrapper around a dummy UIView that serves as the drawable for VLCMediaPlayer.
The issue occurs as soon as playback happens. The SwiftUI views no longer updates/responds to property changes. In this example, clicking the Stop button won't change it back to Play, even as video playback is toggled on/off correctly. If I disable video playback, the buttons behave as you would expect.
The log is below (Play button clicked at 11:07:45, Stop button clicked at 11:07:55). Again, video playback works fine, the issue is only with SwiftUI views stop getting updated by property bindings.
2021-01-08 11:07:39.318613-0800 SwiftUISimplePlayback[44958:2512639] creating player instance using shared library 2021-01-08 11:07:39.455270-0800 SwiftUISimplePlayback[44958:2512639] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600001f73640> F8BB1C28-BAE8-11D6-9C31-00039315CD46 2021-01-08 11:07:45.550031-0800 SwiftUISimplePlayback[44958:2512639] creating player instance using shared library [h264 @ 0x7ffe9e0c4200] Overread VUI by 8 bits 2021-01-08 11:07:49.317337-0800 SwiftUISimplePlayback[44958:2513399] [ddagg] AggregateDevice.mm:820 couldn't get default input device, ID = 0, err = 0! 2021-01-08 11:07:49.495123-0800 SwiftUISimplePlayback[44958:2513633] [aurioc] AURemoteIO.h:323:entry: Unable to join I/O thread to workgroup ((null)): 2 2021-01-08 11:07:55.532741-0800 SwiftUISimplePlayback[44958:2512639] creating player instance using shared library [h264 @ 0x7ffe9f871e00] get_buffer() failed [h264 @ 0x7ffe9f871e00] thread_get_buffer() failed [h264 @ 0x7ffe9f871e00] decode_slice_header error [h264 @ 0x7ffe9f871e00] no frame!