Closed robUx4 closed 2 years ago
It seems that using MF_D3D12_SYNCHRONIZATION_OBJECT
is actually only supported in Win11 (and the GDK). The mfd3d12.h
header doesn't have any versioning for those, nor for IMFD3D12SynchronizationObjectCommands
and IMFD3D12SynchronizationObject
.
The code doesn't leak ID3D12Fence
on Windows 11, but it does report some object leaks with some RefCount
at 0 (similar to the ones on Win10) and an upper object with a RefCount
of 2.
The first report is expected. Calling ReportLiveDeviceObjects before calling MFShutdown & releasing the IMFSourceReader pointer will result in lots of live objects. Both MF platform (controlled by MFStartup/Shutdown) and SourceReader tend to cache objects for re-use in the event a user wanted to re-use the decoder/sourcereader object (it will start decoding video faster on re-use). If you see an increasing number of objects on re-use or full cleanup then there would definitely be a leak bug.
There were known issues in Win10's implementation of DX12 support. We actually have a servicing patch which should bring this fix to Win10 within the next month or two.
However, Win11 should be working correctly today. Would you be able to share the log from Win11?
The leak doesn't happen on Windows 11.
It is indeed normal to get the first report of live objects. The goal of this log is to identify the type for each pointer. The real issue is the report after we close the app/process. The pointers remaining should not be there and correspond to ID3D12Fence
objects.
We noticed the leak on Windows 10 because it does grow significantly over times (by the thousands). This simple example just shows one way to get it. I'll check with the new Windows 10 release if the bug is still there.
As mentioned in https://github.com/microsoft/media-foundation/issues/21#issuecomment-1010985241 I have tried to get D3D12 decoding with Media Foundation. It more or less works, but eventually it leaks internal
ID3D12Fence
each time it's created. I can end up with thousands of deadID3D12Fence
in my process.To exhibit the issue I made this sample code which decodes a frame, attempt to drain, flushes and then exit.
When you run this code, you can see a report of live objects before the program exits, with a lot of internal things to the Media Foundation decoder, ie things I did not create myself.
When the app is closing, there is this report, where the pointers correspond to the
ID3D12Fence
seen above:I tried using the IMFD3D12SynchronizationObject and IMFD3D12SynchronizationObjectCommands interfaces but with no luck.