Media (Intel® Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools like Intel® oneAPI Video Processing Library and Intel® Media SDK
Announcements
The Intel Media SDK project is no longer active. For continued support and access to new features, Intel Media SDK users are encouraged to read the transition guide on upgrading from Intel® Media SDK to Intel® Video Processing Library (VPL), and to move to VPL as soon as possible.
For more information, see the VPL website.

MFXClose hangs infinite when using HEVC plugin

Artur_M_
Beginner
3,171 Views

Hi,

Basic info:
OS Type: Windows 10 Enterprise x64
CPU Type: Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
Intel iGPU: Intel HD Graphics 4600
Intel Driver: 
20.19.15.4380

What and how am I doing (note all below is on Hardware plugin):

I am using HEVC decoding of multiple streams at the same time. I am using following pattern in following sequence:
Create session/init/query/decoder and load plugin by GUID - MFXVideoUSER_Load(Session, HW_plugin_GUID, 1)
some parameters: MFX_IMPL_HARDWARE_ANY with MFX_IMPL_VIA_D3D11,
                           AsyncDepth = 4, 
                           
MFX_BITSTREAM_COMPLETE_FRAME is set, 
Decode frame(s)/syncoperation
Flush decoder (with decode calls with NULL)
Destruct decoder and unload plugin by GUID - MFXVideoUSER_UnLoad(session, HW_plugin_GUID)

My issue:

Sometimes (I have not found a pattern) my application hangs forever when destroying the decoder. I have traced the CallStack:
     [External Code]    
     igd11dxva64.dll!00007ff92aba678d()    Unknown
     igd11dxva64.dll!00007ff92aac3b84()    Unknown
     igd11dxva64.dll!00007ff92ac7dce9()    Unknown
     igd11dxva64.dll!00007ff92ac67d52()    Unknown
     igd11dxva64.dll!00007ff92ac57fb6()    Unknown
     igd11dxva64.dll!00007ff92ac54dcf()    Unknown
     [External Code]    
     libmfxhw64.dll!00007ff92dd93d34()    Unknown
     libmfxhw64.dll!00007ff92dd93d94()    Unknown
     libmfxhw64.dll!00007ff92dda4deb()    Unknown
     libmfxhw64.dll!00007ff92dda4d04()    Unknown
     libmfxhw64.dll!00007ff92ddb6577()    Unknown
     libmfxhw64.dll!00007ff92ddb62f0()    Unknown
     libmfxhw64.dll!00007ff92ddb6824()    Unknown
     libmfxhw64.dll!00007ff92ddac8ff()    Unknown
     [External Code]    
     MFXVideoSession::Close()
     MFXVideoSession::~MFXVideoSession()

So MFXVideoSession destructor calls MFXClose and this function never returns.

How to reproduce:

Well it can be reproduced even with one application running and trying to create a decoder (same sequence described above) -> decode one frame -> destroy decoder. do this 1000 times right after each other. Sometimes the application will hand forever.
It is easier for me to reproduce if I run multiple separate applications that do the same (4-5 app with 1000 iterations each), some of the applications will hang .. sometimes its 1 that hangs, sometimes 2..and sometimes all finish.

Question:

Is there something I am missing? Some call to release differently. I am basically using Procedure B according to https://software.intel.com/en-us/node/562446

Is there any workaround / fix you can recommend?

I have attached the one frame that I am decoding in the application.(but i can reproduce this with other streams as well). NOTE the file extension is txt(because i can not upload files without extension), but its a binary file, so just remove the extension.

Its basically not a question of IF this hang happens, but WHEN.

Please let me know if you need more info.

Best regards,

Artur.

0 Kudos
25 Replies
Mark_L_Intel1
Moderator
538 Views

Hi Artur,

Could you clarify?

1. You can still reproduce this on the latest release.

2. The report you did is the system inform when the problem happened.

Mark

0 Kudos
Artur_M_
Beginner
538 Views

Hi Mark,

1. no because as i wrote before - 2016.0.2 - has a bug that can not be tested with.

2. Yes it is the same machine, however since there have been windows updates. 

So my test has been on MediaSDK 2016.0.1 version. and as i can not test on new version i can not verify if it is fixed. once you have a new version of media sdk that has fixed the other bug i can test this one.

 

And i have just run the same test and it still fails on the system you have the info on. and it fails very consistently almost every time, you dont even need to stress as much, you can make it fail with few instances.

here is a stack:

     sample_decode.exe!MFXVideoDECODE::DecodeFrameAsync(mfxBitstream * bs, mfxFrameSurface1 * surface_work, mfxFrameSurface1 * * surface_out, _mfxSyncPoint * * syncp) Line 125    C++
>    sample_decode.exe!CDecodingPipeline::RunDecoding() Line 1613    C++
     sample_decode.exe!wmain(int argc, wchar_t * * argv) Line 639    C++

this time it fails in decode.

 

0 Kudos
Mark_L_Intel1
Moderator
538 Views

Hi Artur,

I am starting to reproduce it but I can not. I think this might require a specific device.

I did like this:

1. Go to https://x265.com/hevc-video-files/

2. Download the file Tears_400x265.mp4, the resolution is 1080p.

3. Convert it to the bit stream with the following command: > ffmpeg -i Tears_400x265.mp4 -vcodec copy -an -bsf hevc_mp4toannexb Tears_400x265.265.

4. Compile the sample_decode.exe with the last code from GitHuB

5. Changed the batch file to point to the output in #3:

for /l %%x in (1, 1, 100) do (
start sample_decode.exe h265 -hw -d3d11 -i Tears_400x265.265 -f 30 -p 33a61c0b4c27454ca8d85dde757c6f8e
)

The code opens many console immediately at the same time, I have to wait until all of them complete, it took a while but all the processes runs successfully with out any problem, I run the batch file several time and every time I got the same result.

I used a SkyLake machine(6 generation core) and the Media Server Studio Pro Edition) in Windows 10, the sample code is download from https://github.com/Intel-Media-SDK/samples

Also I assumed you didn't change any code before you run the sample_decode.exe, right?

Mark

0 Kudos
Artur_M_
Beginner
538 Views

Hi Mark,

I have been using those files already, but i tried again. and the thing is the way to reproduce this is by having 1 process with multiple decoders so the memory on the iGPU is maxed. And this can only be done on NON Skylake. the 4 Gen Haswell has a 1.8ish Gb memory maximum pr process. 

So my test uses multiple decoder instances and if i consume more than the max amount of memory available the MFXClose hangs forever when trying to close session. 

the trick is to use all memory from one process. and this is even easier to reproduce on windows 8.1 as on win 10 it is possible to use more memory as long as you are using different processes.

So to reproduce you need:
- NON Skylake CPU 
- Use one process to decode multiple H265 streams
- this will make the MFXClose hang forever.

0 Kudos
Mark_L_Intel1
Moderator
538 Views

Thanks Artur and sorry for take so long to come back this question,

I want to try it again but I have a few questions:

1. Could you check my reproduce step and confirm if it is correct?

2. About your suggestion, I think you are suggesting the processor older than skylake, also, how could I confirm "consume more than the max amount of memory available"

Mark

0 Kudos
Reply