Two simultaneous player instances seem to cause deadlock on iOS

This forum is about all development around libVLC.
Auritus
New Cone
New Cone
Posts: 4
Joined: 07 Jun 2018 16:16

Two simultaneous player instances seem to cause deadlock on iOS

Postby Auritus » 07 Jun 2018 16:51

Hello,

I am using the libvlc within a C# Xamarin project to target UWP, Android and iOS. We would like to have an application that is able to play two (remote) streams simultaneously. While this works well on UWP and Android, there is an issue with iOS which I cannot figure out - although I tried everything I can think of.
  • I am creating two instances of the libvlc, by calling

    Code: Select all

    libvlc_new
  • Then I pass these handles to calls to

    Code: Select all

    libvlc_media_player_new
    That way, I should have two independent player instances.
  • Afterwads, I load one URL for each player instance, assign it to the player(s) and start the playback.

    Code: Select all

    media = libvlc_media_new_location(instanceHandle, url); libvlc_media_player_set_media(playerHandle, media); libvlc_media_release(media); libvlc_media_player_play(playerHandle);
  • Until now, everything works fine. Both videos are being played. When I now change the media for one player, it usually works. But as soon as I change the media for the second player one of the calls to libvlc_media_player_stop, libvlc_media_player_set_media or libvlc_media_player_play never returns and blocks the thread I am working in forever.

    Currently, the sequence is the following, in pseudocode. I use a queue and a timer to achieve the delay:

    Code: Select all

    libvlc_media_player_set_pause(playerHandle, 1); delay(100ms); libvlc_media_player_stop(playerHandle); delay(100ms); // When the event manager reports the stop state: libvlc_media_player_set_media(playerHandle, newMedia); // When the event manager reports the new media (mediachanged): libvlc_media_player_play(playerHandle);
I cannot find out whats going wrong. I tried several things, but could not get rid of the blocking function call.
  • I used a custom renderer instead of the UIView (via libvlc_media_player_set_nsobject) to make sure its not caused by an interaction with the UI thread.
  • I disabled animations for the UIView acting as render target by calling RemoveAllAnimations, RemoveFromSuperLayer and Actions = null.
  • I started a separate thread for every libvlc call that has to do with the media player.
  • I added a delay between every libvlc call.
  • I stopped the other player first and then restarted both.
  • I tried the media list and media list player interfaces - the effect stays the same.
  • I tried to completely recreate the player instance, but then the call to libvlc_media_player_release blocks.
  • The log output sometimes shows slicing errors when stopping a stream. Not sure if this is related to the issue.
Any ideas or hints are welcome. I wonder if there is another approach to handle two players, or if this is indeed an issue with the iOS and libvlc combination.
Thanks.

Auritus
New Cone
New Cone
Posts: 4
Joined: 07 Jun 2018 16:16

Re: Two simultaneous player instances seem to cause deadlock on iOS

Postby Auritus » 08 Jun 2018 11:22

Obviously, disabling audio by creating the instance with --no-audio can be used to avoid the blocking call. Not a perfect solution, but acceptable for now. However, disabling audio results in some streams not being rendered.

fkuehne
Developer
Developer
Posts: 7264
Joined: 16 Mar 2004 19:37
VLC version: 0.4.6 - present
Operating System: Darwin
Location: Germany
Contact:

Re: Two simultaneous player instances seem to cause deadlock on iOS

Postby fkuehne » 09 Jun 2018 10:00

Can you provide a sample project? and how do you access libvlc? Do you use https://github.com/videolan/libvlcsharp ?
VideoLAN
Felix Paul Kühne
Medic. VLC developer for appleOS since before you were born.
Blog: https://www.feepk.net

Auritus
New Cone
New Cone
Posts: 4
Joined: 07 Jun 2018 16:16

Re: Two simultaneous player instances seem to cause deadlock on iOS

Postby Auritus » 09 Jun 2018 15:11

Thanks for your response. I am using the NuGet Package VideoLAN.LibVLC.iOS (https://github.com/mfkl/libvlc-nuget) to access the native C library directly. So I built something which is similar to the C# version you referenced.

I will try to provide a project with the minimum code required to reproduce this as soon as possible.

The streams I currently use for tests are:
  • https://zdf0910-lh.akamaihd.net/i/dach10_v1@392872/master.m3u8
  • https://video-dev.github.io/streams/x36xhzz/x36xhzz.m3u8
  • rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov
  • http://live-lh.daserste.de/i/daserste_de@91204/master.m3u8
The first one is the one not working when disabling Audio. This happens on any platform, but at least for me that is not important since I would prefer having audio in the end.

fkuehne
Developer
Developer
Posts: 7264
Joined: 16 Mar 2004 19:37
VLC version: 0.4.6 - present
Operating System: Darwin
Location: Germany
Contact:

Re: Two simultaneous player instances seem to cause deadlock on iOS

Postby fkuehne » 09 Jun 2018 18:55

Can you make sure that your libvlc version is up-to-date? I added a fix for a similar problem just a few days ago.
VideoLAN
Felix Paul Kühne
Medic. VLC developer for appleOS since before you were born.
Blog: https://www.feepk.net

Auritus
New Cone
New Cone
Posts: 4
Joined: 07 Jun 2018 16:16

Re: Two simultaneous player instances seem to cause deadlock on iOS

Postby Auritus » 12 Jun 2018 08:37

Ok, thanks for the hint. I will make an update first.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 35 guests