locked
MediaFoundation Transform crashing on Surface

    Question

  • Hello, I'm developing a solution based on the GrayscaleTransform Effect found on the MediaCapture sample and although it works fine on my laptop, it hangs on a Surface RT device. The sample also hangs on the tablet.

    I've found on this thread that the Grayscale sample is not optimized. My algorithm is fairly resource intensive as it analyses the image, and it calls back the app returning information from the image.

    I have already limited the image resolution to 640x480, which is a good resolution to perform the analysis, and I don't mind losing framerate.

    If I set my laptop to the Power Saver power plan, which limits its CPU to ~1.2GHz, it decreases the framerate and the transform still works flawlessly.

    On a Surface RT the transform stop working after processing one frame. If I just memcpy the frame contents, the transform doesn't hang.

    It's my first time working with MFTs. Is there any pointers on how can I change my transform to make it work on Windows RT?

    Thanks

    Monday, April 29, 2013 9:02 PM

Answers

  • Hello Renato,

    I spent some time today looking at your hang. From what I can see the hang is due to a complex deadlock condition between two mfplat worker threads. From my initial investigation the modules that are creating and holding the outstanding kernel objects that are causing the deadlock appear to be in the nvCameraMFT module. That said here is my evidence (note: public symbols used).

    CritSec +90a1c9c at 090a1c9c
    WaiterWoken        No
    LockCount          0
    RecursionCount     1
    OwningThread       10b0 <- Thread 19
    EntryCount         0
    ContentionCount    1
    *** Locked

    CritSec +90d6d14 at 090d6d14
    WaiterWoken        No
    LockCount          1
    RecursionCount     1
    OwningThread       1724 <- Thread 30
    EntryCount         0
    ContentionCount    1
    *** Locked


    Thread 19

    ntdll!NtWaitForSingleObject
    KERNELBASE!WaitForSingleObjectEx
    nvCameraMFT!DllUnregisterServer
    nvCameraMFT!DllUnregisterServer
    nvCameraMFT!DllUnregisterServer
    nvCameraMFT!DllUnregisterServer
    nvCameraMFT!DllUnregisterServer
    mfplat!CSerialWorkQueue::QueueItem::ExecuteWorkItem
    mfplat!CSerialWorkQueue::QueueItem::OnWorkItem
    mfplat!CSerialWorkQueue::QueueItem::OnWorkItemAsyncCallback::Invoke
    mfplat!CBaseWorkQueue::HandleConcurrentMMCSSEnter
    ntdll!TppWorkpExecuteCallback
    ntdll!TppWorkerThread
    kernel32!BaseThreadInitThunk
    ntdll!RtlUserThreadStart


    Thread 30

    ntdll!NtWaitForSingleObject
    ntdll!RtlpWaitOnCriticalSection
    ntdll!RtlpEnterCriticalSectionContended
    nvCameraMFT!DllUnregisterServer
    nvCameraMFT!DllUnregisterServer
    MFReadWrite!CMFReadWriteTransform::SetupOutputBuffers
    MFReadWrite!CMFReadWriteTransform::ProcessOutput
    MFReadWrite!CMFReadWriteTransformChain::ProcessSample
    MFReadWrite!CMFReadWriteTransformChain::OnTransformNeedsInput
    MFReadWrite!CMFReadWriteTransformChain::NotifyTransformEvent
    MFReadWrite!CMFReadWriteTransform::OnMFTEvent
    MFReadWrite!CMFReadWriteTransform::OnMFTEventAsyncCallback::Invoke
    mfplat!CSerialWorkQueue::QueueItem::ExecuteWorkItem
    mfplat!CSerialWorkQueue::QueueItem::OnWorkItem
    mfplat!CSerialWorkQueue::QueueItem::OnWorkItemAsyncCallback::Invoke
    mfplat!CBaseWorkQueue::HandleConcurrentMMCSSEnter
    ntdll!TppWorkpExecuteCallback
    ntdll!TppWorkerThread
    kernel32!BaseThreadInitThunk
    ntdll!RtlUserThreadStart

    Basically it appears that the nvCameraMFT module is deadlocked with itself. If I had the symbols for nvCameraMFT I might be able to tell you more but I don't think that it is necessary. I will report this internally but I would recommend that you take the time to report this to NVidia as well for further investigation.

    Thanks for taking the time to report this,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Tuesday, May 07, 2013 10:12 PM
    Moderator

All replies

  • Hello Renato,

    Does the transform stop working (i.e. the pipeline reports a change in state to "stopped") or does it actually hang? If it is a hang is it a busy hang (i.e. the CPU is at 100%) or is it a deadlock (i.e. two threads are waiting on the same kernel object)?

    I'll do what I can to help but I need more information.

    -James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Monday, April 29, 2013 9:39 PM
    Moderator
  • Hello James,

    It is a deadlock. The same deadlock happens on the sample.

    Monday, April 29, 2013 9:59 PM
  • Hello Renato,

    Please generate two dump files for me. Reproduce the problem (i.e. in the hung state) and take the first dump. Wait for 30 seconds and take the second dump. Once you have them please zip them up and post them to your SkyDrive. Prost a link to them here and I will grab them and take a look.

    Thanks,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Monday, April 29, 2013 10:56 PM
    Moderator
  • Hello James, I generated the dump files and included the symbols.
    https://skydrive.live.com/redir?resid=BBD45C3B10463C94!821&authkey=!AOvNnWFGibPzfVo

    Thanks,
    Renato
    Tuesday, April 30, 2013 7:51 PM
  • Hello Renato,

    I apologize for the late reply. I have been out sick. I hope to be able to look at your dump files tomorrow or Monday. I will let you know what I find.

    Thanks,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Thursday, May 02, 2013 11:50 PM
    Moderator
  • Hello Renato,

    I spent some time today looking at your hang. From what I can see the hang is due to a complex deadlock condition between two mfplat worker threads. From my initial investigation the modules that are creating and holding the outstanding kernel objects that are causing the deadlock appear to be in the nvCameraMFT module. That said here is my evidence (note: public symbols used).

    CritSec +90a1c9c at 090a1c9c
    WaiterWoken        No
    LockCount          0
    RecursionCount     1
    OwningThread       10b0 <- Thread 19
    EntryCount         0
    ContentionCount    1
    *** Locked

    CritSec +90d6d14 at 090d6d14
    WaiterWoken        No
    LockCount          1
    RecursionCount     1
    OwningThread       1724 <- Thread 30
    EntryCount         0
    ContentionCount    1
    *** Locked


    Thread 19

    ntdll!NtWaitForSingleObject
    KERNELBASE!WaitForSingleObjectEx
    nvCameraMFT!DllUnregisterServer
    nvCameraMFT!DllUnregisterServer
    nvCameraMFT!DllUnregisterServer
    nvCameraMFT!DllUnregisterServer
    nvCameraMFT!DllUnregisterServer
    mfplat!CSerialWorkQueue::QueueItem::ExecuteWorkItem
    mfplat!CSerialWorkQueue::QueueItem::OnWorkItem
    mfplat!CSerialWorkQueue::QueueItem::OnWorkItemAsyncCallback::Invoke
    mfplat!CBaseWorkQueue::HandleConcurrentMMCSSEnter
    ntdll!TppWorkpExecuteCallback
    ntdll!TppWorkerThread
    kernel32!BaseThreadInitThunk
    ntdll!RtlUserThreadStart


    Thread 30

    ntdll!NtWaitForSingleObject
    ntdll!RtlpWaitOnCriticalSection
    ntdll!RtlpEnterCriticalSectionContended
    nvCameraMFT!DllUnregisterServer
    nvCameraMFT!DllUnregisterServer
    MFReadWrite!CMFReadWriteTransform::SetupOutputBuffers
    MFReadWrite!CMFReadWriteTransform::ProcessOutput
    MFReadWrite!CMFReadWriteTransformChain::ProcessSample
    MFReadWrite!CMFReadWriteTransformChain::OnTransformNeedsInput
    MFReadWrite!CMFReadWriteTransformChain::NotifyTransformEvent
    MFReadWrite!CMFReadWriteTransform::OnMFTEvent
    MFReadWrite!CMFReadWriteTransform::OnMFTEventAsyncCallback::Invoke
    mfplat!CSerialWorkQueue::QueueItem::ExecuteWorkItem
    mfplat!CSerialWorkQueue::QueueItem::OnWorkItem
    mfplat!CSerialWorkQueue::QueueItem::OnWorkItemAsyncCallback::Invoke
    mfplat!CBaseWorkQueue::HandleConcurrentMMCSSEnter
    ntdll!TppWorkpExecuteCallback
    ntdll!TppWorkerThread
    kernel32!BaseThreadInitThunk
    ntdll!RtlUserThreadStart

    Basically it appears that the nvCameraMFT module is deadlocked with itself. If I had the symbols for nvCameraMFT I might be able to tell you more but I don't think that it is necessary. I will report this internally but I would recommend that you take the time to report this to NVidia as well for further investigation.

    Thanks for taking the time to report this,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Tuesday, May 07, 2013 10:12 PM
    Moderator
  • Hello James,

    I will try to follow up with nVidia.

    Thanks for your time.

    Renato

    Wednesday, May 08, 2013 2:39 AM