-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Manually quit when the OS tells us to update #13614
Conversation
Refer to https://docs.microsoft.com/en-us/windows/win32/rstmgr/guidelines-for-applications The OS will send us a WM_QUERYENDSESSION when it's preparing an update for our app. It will then send us a WM_ENDSESSION, which gives us a small timeout (~30s) to actually shut down gracefully. After that timeout, it will send us a WM_CLOSE. If we still don't close after the WM_CLOSE, it'll force-kill us (causing a crash which will be bucketed to moapphang). We will manually start a quit, so that we can persist the state. If we refuse to gracefully shut down, the OS will crash us to focefully terminate us. We choose to quit here, rather than just close, to skip over any warning dialogs (e.g. "Are you sure you want to close all tabs?") which might prevent a WM_CLOSE from cleanly closing the window. This will cause a appHost._RequestQuitAll, which will notify the monarch to collect up all the window state and save it. This "crash" caused by the OS force killing us constitutes 80% of all our crashes. 80%. See MSFT:38947155, MSFT:38877540, MSFT:21058878, MSFT:31710054, MSFT:39764652, MSFT:26883776. Closes #13569
This comment has been minimized.
This comment has been minimized.
TraceLoggingWrite( | ||
g_hWindowsTerminalProvider, | ||
"QueryEndSession", | ||
TraceLoggingDescription("Emitted when the OS has begun the process of updating the Terminal"), | ||
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE), | ||
TraceLoggingKeyword(TIL_KEYWORD_TRACE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this event redundant with the one for WM_ENDSESSION
? If we return true
here, then almost always we should also receive a WM_ENDSESSION
event anyways right?
In that case you could remove this entire case
because the DefWindowProc
already returns true
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh, yea probably. I was thinking originally that we would shove some logic in there, but turns out we really don't need it.
Do we want to service this? CC @DHowett |
Talked to Dustin about this earlier, and the suggestion was meh. It's a large number of raw crashes, but ultimately it's one per user. Probably fine to just wait till it bubbles up the normal way. |
Hello @zadjii-msft! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
Refer to https://docs.microsoft.com/en-us/windows/win32/rstmgr/guidelines-for-applications The OS will send us a WM_QUERYENDSESSION when it's preparing an update for our app. It will then send us a WM_ENDSESSION, which gives us a small timeout (~30s) to actually shut down gracefully. After that timeout, it will send us a WM_CLOSE. If we still don't close after the WM_CLOSE, it'll force-kill us (causing a crash which will be bucketed to moapphang). We will manually start a quit, so that we can persist the state. If we refuse to gracefully shut down, the OS will crash us to focefully terminate us. We choose to quit here, rather than just close, to skip over any warning dialogs (e.g. "Are you sure you want to close all tabs?") which might prevent a WM_CLOSE from cleanly closing the window. This will cause a appHost._RequestQuitAll, which will notify the monarch to collect up all the window state and save it. This "crash" caused by the OS force killing us constitutes 80% of all our crashes. 80%. See MSFT:38947155, MSFT:38877540, MSFT:21058878, MSFT:31710054, MSFT:39764652, MSFT:26883776. Closes #13569 It also fixes the issue where if you've got Terminal Dev running (outside VS), and you try to Deploy, you have to make sure to close the "Are you sure you want to close all tabs" dialog before the deployment can proceed. A deploy in VS sends the same sequence of messages as a real update. (cherry picked from commit b3604ba) Service-Card-Id: 84836638 Service-Version: 1.15
🎉 Handy links: |
Refer to https://docs.microsoft.com/en-us/windows/win32/rstmgr/guidelines-for-applications
The OS will send us a WM_QUERYENDSESSION when it's preparing an
update for our app. It will then send us a WM_ENDSESSION, which gives
us a small timeout (~30s) to actually shut down gracefully. After
that timeout, it will send us a WM_CLOSE. If we still don't close
after the WM_CLOSE, it'll force-kill us (causing a crash which will be
bucketed to moapphang).
We will manually start a quit, so that we can persist the state. If we refuse to
gracefully shut down, the OS will crash us to focefully terminate us. We
choose to quit here, rather than just close, to skip over any warning dialogs
(e.g. "Are you sure you want to close all tabs?") which might prevent a WM_CLOSE
from cleanly closing the window.
This will cause a appHost._RequestQuitAll, which will notify the
monarch to collect up all the window state and save it.
This "crash" caused by the OS force killing us constitutes 80% of all our crashes. 80%. See MSFT:38947155, MSFT:38877540, MSFT:21058878, MSFT:31710054, MSFT:39764652, MSFT:26883776.
Closes #13569
It also fixes the issue where if you've got Terminal Dev running (outside VS), and you try to Deploy, you have to make sure to close the "Are you sure you want to close all tabs" dialog before the deployment can proceed. A deploy in VS sends the same sequence of messages as a real update.