Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xluogithub opened this issue Nov 13, 2023 · 8 comments

Comments

@xluogithub
Copy link

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(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
Copy link
Author

stack-tracing

@robmikh
Copy link
Owner

robmikh commented Nov 13, 2023

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

@xluogithub
Copy link
Author

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

@xluogithub
Copy link
Author

@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
Copy link
Author

@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.

@robmikh
Copy link
Owner

robmikh commented Nov 18, 2023

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.

@xluogithub
Copy link
Author

@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
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants