-
-
Notifications
You must be signed in to change notification settings - Fork 414
Reworked VlcManager architecture #490
Reworked VlcManager architecture #490
Conversation
Hi. I saw your message. I am currently without computer. I would like to check out your branch to give it a look but it would not be soon. |
Thanks for your answer. I'm currently out for holidays and will return on december the 1st. |
Hi @dilandau2001 , any time for a review? |
Today, I will give it a try. sorry for the delay |
I did a test with this code. I used sample: MultiplePlayers. I did it multiple times. I could reproduce a small and consistent leak but I haven't being able yet to identify the leak as apparently handlers are bein unregistered correctly. Also VlcControl.EndInit has become a bit slower than before. Don't know the reason either. I would sepparate the part of the code that requires to run in the ui thread (apparently only the handle assingn) from the part of the code that can run in a different thread so the time the ui is blocked is reduced to the minimum. |
Thanks for the review!
Seems quite normal : the libvlc instance is not shared anymore, which means we need to call You can still create a new media player with a shared VlcManager if you want, because this constructor is now public. https://github.com/ZeBobo5/Vlc.DotNet/pull/490/files#diff-478680d15152ff2c027403f8f9ee05c9R24. For the leak, I did try that and noticed the same thing. However, I'm not a memory leak expert, and concluded that the leak wasn't meanignful and was likely caused by the runtime or the environment and was normal. If you think that something is wrong, we will need to dig deeper. Can that be an issue on libvlc's side? |
Is it really long? Do we really need to do something about it? Spawning a thread/awaiting something in the constructor feels dangerous (race conditions, hard error catching...) for me without a good reason. |
Testing performance, starting and closing players several times I could reproduce the following crash: Faulting application name: Samples.WinForms.MultiplePlayers.exe, version: 0.0.0.0, time stamp: 0xba087546 |
I was wrong, old code leaks the same amount... |
Well, it depends what is the source of the leak. If it is leaking handlers then that will eventually rise an outofmemory exception. If it is rubbish for the GC to work with then you can survive with it. |
The architecture of this PR is where I want to go with Vlc.DotNet : the Libvlc instance is not shared anymore, allowing it to be released properly and passing different options. Sharing libvlc instance leaks only one instance per run, but that doesn't mean that the code is better IMHO. We need to fix that crash before merging |
Can you reproduce the crash in your environment?... just opening 10-15 players with Vlc 3.0.4. |
I didn't have time to try it yet. ntdll doesn't really mean anything since it's used everywhere... |
Despite my tests, I couldn't reproduce this on my windows 10... Anyone else reproduces the crash? Anyone else can try this? I launched a debug session of |
@dilandau2001: which windows version? |
I did my tests with Windows 10 |
@dilandau2001 Can you share your full code for repro please? |
@jeremyVignelles I am facing this issue also , and tested on Windows 10 and Windows server 2012 r2 |
to ensure proper loading/unloading of libvlc*.dll Fixes ZeBobo5#482
9497221
to
3cd1f1b
Compare
Now waiting asynchronously rather that blocking the ThreadPool's thread.
I'm back with this PR after a long time! @dilandau2001 , After testing, I disagree with that part:
With this code in MultiplePlayers.Forms1: panel.Controls.Add(player);
var sw = new Stopwatch();
sw.Start();
player.EndInit();
Debug.WriteLine($"Elapsed {sw.ElapsedMilliseconds}ms"); Before this PR:
After:
I guess we could do better if we passed the media player to the control, but I think it is acceptable as-is. I still can't reproduce your crash... can you try to clean your code? Are you on a x86 windows? I can't figure out what's the difference between your machine and mine. If anyone has a clue, he's welcome... |
I will do a retry as soon as I can. |
@dilandau2001 Did you have time to have a look at this? |
not yet, I expect to do it before sunday.
El jue., 24 ene. 2019 a las 8:27, Jérémy VIGNELLES (<
notifications@github.com>) escribió:
… @dilandau2001 <https://github.com/dilandau2001> Did you have time to have
a look at this?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#490 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMPWpaBPerADA12O7iD5NnJUOROdPu2iks5vGWBYgaJpZM4Yv7_Z>
.
|
Hello I gave it another try. This is how I did it: Reproduction steps:
Notes: Tips: |
Hello, thanks for the explanations, will try that. is that possible that the crash comes from libvlc itself? frozen video is not a good sign. Your solution of making child process is good for video wall applications (I'm using this technique too) but doesn't apply to all cases, when video are embedded in a GUI for example. |
Well I actually embed the videos inside my Gui using Win32 SetParent functions and similar things. Only for Windows Forms though. Regarding the crash. It did not happen in vlc 2.2.4 so it seems something from vlc itself. |
to ensure proper loading/unloading of libvlc*.dll
Fixes #482
Fixes #389
Replaces #486
A few words about the implementation :
Removed useless
VlcInteropsManager
abstract classIntroduced a VlcLibraryLoader class : It loads the DLL files and DLL functions. Static methods are there to ensure that only one instance is there per path, and that the DLL is properly unloaded when it's not needed anymore.
VlcManager is not tied to a dll path anymore (it's VlcLibraryLoader's job). Instead it's tied to a VlcInstance, i.e. libvlc_new
libvlc instances are not cached anymore: This means that two different players can (will by default) use two different libvlc instances, each having potentially different media player options
VlcManager.CreateNewInstance does not exist anymore : instead, arguments are passed to VlcManager's constructor and libvlc instance is created in the constructor.
This means that EnsureVlcInstance is not needed anymore.
Behavior changed : No options are passed to the MediaPlayer by default. To restore previous behavior, set:
/cc @dilandau2001