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

Take Snapshot button crashes the application #43

Open
benschop-it opened this issue Feb 17, 2022 · 6 comments
Open

Take Snapshot button crashes the application #43

benschop-it opened this issue Feb 17, 2022 · 6 comments

Comments

@benschop-it
Copy link

I am running the code (Debug X64 both with VS2019 and VS2022), and it crashes when I click on the Take Snapshot button. The crash happens in:
auto file = co_await m_savePicker.PickSaveFileAsync();
I've seen people reporting crashes in the FileSavePicker dialog, but the reported tickets have been closed with the advice to Initialize the object with Window handle, which you already do:
window.InitializeObjectWithWindowHandle(savePicker);
The CapturePicker however does work, but only when indeed you initialize it with the window handle.
It seems there is still something wrong with the FileSavePicker.

@robmikh
Copy link
Owner

robmikh commented Feb 17, 2022

What build/version of Windows do you see this behavior on?

@benschop-it
Copy link
Author

benschop-it commented Feb 17, 2022

I am running Version 20H2 (OS Build 19042.1466).
The problem only occurs in the C++ Win32 project. In a C++ UWP project it works fine.

@robmikh
Copy link
Owner

robmikh commented Feb 17, 2022

Hmmm, my home machine is on a slightly newer build (19043.1526) and I'm unable to reproduce it. I'll see if I can setup a machine with the same build.

@zgf
Copy link

zgf commented Feb 20, 2022

I have the same problem when I build x64 and run on win 10.0.119043.
crash at auto file = co_await m_savePicker.PickSaveFileAsync();

@robmikh
Copy link
Owner

robmikh commented Feb 20, 2022

That's interesting. Could you try attaching a debugger and do the following:

  • In WinMain, break in and note the thread Id of the UI/main thread.
  • Just before the line that throws/crashes, break in and check the thread Id of the current thread.

Are they the same? If not, this may be the source of the issue. Try calling co_await m_mainThread before the line that throws/crashes and see if that fixes it.

@benschop-it
Copy link
Author

I tried what you suggested. Both are the same thread.

In WinMain:
Not Flagged > 0x00007898 0x00 Main Thread Main Thread Win32CaptureSample.exe!WinMain

In App.TakeSnapshotAsync:
Not Flagged > 0x00007898 0x00 Main Thread Main Thread Win32CaptureSample.exe!App::TakeSnapshotAsync$_ResumeCoro$1

However, the exception is thrown in another thread:
Not Flagged > 0x0000A358 0x00 Worker Thread ntdll.dll thread Win32CaptureSample.exe!_CxxThrowException

This thread starts at base.h:
inline void __stdcall resume_background_callback(void*, void* context) noexcept
{
coroutine_handle<>::from_address(context)();
};

Maybe it is expected that this code is running on a different thread, I did not look into the details.

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

3 participants