Win32CaptureSample icon indicating copy to clipboard operation
Win32CaptureSample copied to clipboard

winrt::windows::Graphics::Capture::GraphicsCaptureSession.Close() hangs on Windows 10

Open xluogithub opened this issue 2 years ago • 8 comments

In a loop of capturing all open application windows' images, GraphicsCaptureSession.Close() occasionally hangs. Yesterday I was able to duplicate this issue and collected all dump files. Below is the code flow: App.cpp winrt::GraphicsCaptureItem App::StartCaptureFromWindowHandle(HWND hwnd) { auto item = util::CreateCaptureItemForWindow(hwnd); StartCaptureFromItem(item); return item; }

void App::StartCaptureFromItem(winrt::GraphicsCaptureItem item) { m_capture = std::make_unique<SimpleCapture>(m_device, item, m_pixelFormat);

auto surface = m_capture->CreateSurface(m_compositor);
m_brush.Surface(surface);

m_capture->StartCapture();

}

SimpleCapgture.cpp void SimpleCapture::Close() { auto expected = false; if (m_closed.compare_exchange_strong(expected, true)) { m_session.Close(); ---- ***** Issue is here and it's hanging on Close() and never finish this Close() call m_framePool.Close();

}

} I have created this instance on the feeback and it's link is https://aka.ms/AAnlnr9. The attached zip file contains dump files for CaptureService, DWM.exe and my application iClicker Cloud's dmp and pdb files, and stack trace file. @robmikh what could be a root cause to hanging on m_session.Close()? Please let me know if you need additional info.

xluogithub avatar Nov 13 '23 15:11 xluogithub

stack-tracing

xluogithub avatar Nov 13 '23 19:11 xluogithub

Unfortunately, it looks like the zip is corrupted. I'm unable to open it.

robmikh avatar Nov 13 '23 23:11 robmikh

Sorry and I will try to rezip and upload it again to the feeback. Thanks.

xluogithub avatar Nov 13 '23 23:11 xluogithub

@robmikh just attached another zip file to the feefback that is keep-surfacepro-dump-on-capture.zip. Hope that this time the file would be fine.

xluogithub avatar Nov 13 '23 23:11 xluogithub

@robmikh are you getting a chance to take a look at dump files. If you still face the issue to download my zip file, I can upload it to my google drive, then you can download the zip file from a google link, but I need your email address to give you access. My team has a December release, so we need to fix this issue on this release. Could you point to some area, we can modify my application to avoid this kind of hanging? Thanks.

xluogithub avatar Nov 17 '23 15:11 xluogithub

Sorry, I took a look at your second zip earlier but I didn't have time to respond. It looks like the app is waiting on the service, but the service dump has nothing interesting in it. I'm guessing it's not the same instance, and the original instance had crashed. I don't have any guidance at the moment, this needs further investigation. With the holidays and a lack of leads it might be awhile before I can come back to this.

robmikh avatar Nov 18 '23 00:11 robmikh

@robmikh My team has a December release, so we need to fix this issue on December release. Could you point to some area, I can modify my application to avoid this kind of hanging? Thanks.

xluogithub avatar Dec 05 '23 15:12 xluogithub

@robmikh it has been a while. It's so close to my desktop app's Dec release deadline. Could you take a time to respond to my above question. Really appreciate your help to find a solution to avoid this kind of hanging.

xluogithub avatar Dec 15 '23 18:12 xluogithub