SuRGeoNix / Flyleaf

Media Player .NET Library for WinUI 3/ WPF/WinForms (based on FFmpeg/DirectX)
GNU Lesser General Public License v3.0
712 stars 100 forks source link

Memory Leakage #466

Closed cxgym closed 4 months ago

cxgym commented 4 months ago

【v3.7.48】Opening multiple streams in the same application results in a continuous increase in memory until the program crashes, log is not have error, but Opening single streams it is no problem.

SuRGeoNix commented 4 months ago

Once again @cxgym by trying to describe an issue with 1 line and expecting me to understand it and fix it makes no sense.

cxgym commented 4 months ago

I can only describe the problem I encountered because there is no valuable reference in the logs. Opening multiple streams in an application is normal if software is used to decode it. If I enable D3D hardware acceleration, it will run normally on some machines, while running on another machine will cause memory leakage. However, opening only one stream is not a problem

cxgym commented 4 months ago

520

cxgym commented 4 months ago

I suspect there is a thread safety issue here

cxgym commented 4 months ago

Hope to give me tips, thanks.

SuRGeoNix commented 4 months ago

Check this https://github.com/SuRGeoNix/Flyleaf/issues/450 and this https://github.com/SuRGeoNix/Flyleaf/discussions/448

cxgym commented 4 months ago

Is it because of a problem with the gpu driver?

cxgym commented 4 months ago

GPU 0 Intel(R) Iris(R) Xe Graphics Drive Version: 31.0.101.4953 Drive Date: 2023/11/7 DirectX Version: 12 (FL 12.1) it is memory leakage

GPU 1 Intel(R) Iris(R) Xe Graphics Drive Version: 27.20.100.8984 Drive Date: 2020/11/19 DirectX Version: 12 (FL 12.1) it is right

SuRGeoNix commented 4 months ago

From what other users said in the past is seems that is related with intel integrated graphics. Not sure if that's intel's issue or the combination of Intel/WPF. I was not able to reproduce it myself yet.

cxgym commented 4 months ago

Config.Decoder.ZeroCopy = FlyleafLib.ZeroCopy.Enabled;
It can indeed solve my problem. but it will affect other functions?

SuRGeoNix commented 4 months ago

Thanks interesting. The only problem by forcing ZeroCopy it would be that you will have visible codec's padding pixels at the sides. (eg. full row of green pixels at the bottom of the frame). By checking the source code it seems that intel driver has the issue with the CopySubresourceRegion. Another open intel issue possible related is this https://community.intel.com/t5/Developing-Games-on-Intel/Memory-leaks-on-Intel-Iris-Xe-graphics/td-p/1585566