N-th VideoView kills CPU
Summary
When a sufficient number of VideoViews are running, the CPU usage explodes (non-linear).
Minimal project and steps to reproduce
You can find an example here: https://github.com/mzotkiew/ManyVLC/tree/master/ManyVLC
What is the current bug behavior?
When N VideoViews are playing everything is in perfect order, say the GPU utilization is around 50% and the CPU utilization is around 20%. When (N+1)th VideoView starts to play, the CPU utilization increases to, say 60%, and (N+2)th VideoView can kill the CPU. N is not constant, but the issue usually happens when N is around 15-20. When the VideoView that caused the issue is stopped, everything goes back to normal. When the VideoView is restarted, the issue may or may not happen again. I haven't found anything in logs. In general, it seems they do not change when the issue occurs.
What is the expected correct behavior?
The CPU utilization stays low.
Environment
- OS: Windows 10 Pro
- Version 1809
- Device: PC
- LibVLC version and architecture 3.0.8.1 (other also), x64 (x86 also)
- LibVLCSharp version 3.3.1.0 (other also)
Possible fixes
I've tried to track the issue, but obtained some strange results. I was expecting that some threads are responsible for the issue, but according to Visual Studio Performance Profiler, all threads running LibVLC are equally responsible for increasing the CPU utilization.
Any suggestions will be appreciated.