Vlc.DotNet icon indicating copy to clipboard operation
Vlc.DotNet copied to clipboard

VlcControl.Stop() deadlock and freeze application!

Open lebtho1878 opened this issue 5 years ago • 8 comments

SourceProvider.MediaPlayer.Stop()

Version 3.0.0

freezes the application

lebtho1878 avatar Mar 29 '19 08:03 lebtho1878

Can you share your full code, please?

Did you try to call Stop() from a VLC callback? https://github.com/ZeBobo5/Vlc.DotNet/wiki/Vlc.DotNet-freezes-(don't-call-Vlc.DotNet-from-a-Vlc.DotNet-callback)

jeremyVignelles avatar Mar 29 '19 08:03 jeremyVignelles

This is in your example Samples.Wpf.Advanced, I changed to Stop

private void OnStopButtonClick(object sender, RoutedEventArgs e)
    {
        control.SourceProvider.MediaPlayer.Stop();
        //this.control?.Dispose();
        //this.control = null;
    }

lebtho1878 avatar Mar 29 '19 09:03 lebtho1878

While I still don't know why the app freeze, I found a workaround:

            ThreadPool.QueueUserWorkItem(_ => control.SourceProvider.MediaPlayer.Stop());

jeremyVignelles avatar Apr 01 '19 21:04 jeremyVignelles

Workaround works for me. Thank you!

lebtho1878 avatar Apr 02 '19 06:04 lebtho1878

yes, If you use event function in VLC Display Callback function, then app will freeze.

wangning08115 avatar Apr 02 '19 06:04 wangning08115

Yes, but that's not the case here, Stop() is invoked on the main thread because it is triggered by a mouse click. I guess that the rule is : don't call Stop() on the same thread that created the Player, but I'm not sure why it does that...

EDIT : Just realized that it's in the WPF control. it must be because the Video callback wants to go to the main thread, locking the callback, while the main thread waits for the Stop() to complete

jeremyVignelles avatar Apr 02 '19 06:04 jeremyVignelles

For your information. Don't call Stop(), Pause() and Play() from main thread. If call then deadlock.

marksard avatar Aug 20 '19 06:08 marksard

@jeremyVignelles EDIT : Just realized that it's in the WPF control. it must be because the Video callback wants to go to the main thread, locking the callback, while the main thread waits for the Stop() to complete.

Thank you for information that the main thread waits for the Stop() to complete. I have a question. It's just stop() function? How about Play(), Pause(), Dispose()?

sunky0 avatar Mar 17 '20 06:03 sunky0