[PR #13614] [MERGED] Manually quit when the OS tells us to update #29658

Open
opened 2026-01-31 09:36:11 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/13614
Author: @zadjii-msft
Created: 7/27/2022
Status: ✅ Merged
Merged: 7/29/2022
Merged by: @undefined

Base: main ← Head: dev/migrie/b/13569-moapphang


📝 Commits (6)

  • afb7f55 Manually quit when the OS tells us to update
  • 1ebe021 spel
  • fd23c55 more spel
  • b212ddc this branch is unused
  • 8a5e3cb Merge remote-tracking branch 'origin/main' into dev/migrie/b/13569-moapphang
  • caf57c3 little cleanup

📊 Changes

4 files changed (+47 additions, -0 deletions)

View changed files

📝 .github/actions/spelling/allow/apis.txt (+3 -0)
📝 src/cascadia/WindowsTerminal/AppHost.cpp (+6 -0)
📝 src/cascadia/WindowsTerminal/IslandWindow.cpp (+37 -0)
📝 src/cascadia/WindowsTerminal/IslandWindow.h (+1 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/13614 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 7/27/2022 **Status:** ✅ Merged **Merged:** 7/29/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/migrie/b/13569-moapphang` --- ### 📝 Commits (6) - [`afb7f55`](https://github.com/microsoft/terminal/commit/afb7f556ac119cecf0463f18746f69d046ab6e72) Manually quit when the OS tells us to update - [`1ebe021`](https://github.com/microsoft/terminal/commit/1ebe021de691448c84c7859d20fcb0e19b64d8e3) spel - [`fd23c55`](https://github.com/microsoft/terminal/commit/fd23c551987073abadd5096bff9113157406b418) more spel - [`b212ddc`](https://github.com/microsoft/terminal/commit/b212ddcfa40500047c75e17a5320da3119042e01) this branch is unused - [`8a5e3cb`](https://github.com/microsoft/terminal/commit/8a5e3cbee795691990b4adb9590a390ef63b1f55) Merge remote-tracking branch 'origin/main' into dev/migrie/b/13569-moapphang - [`caf57c3`](https://github.com/microsoft/terminal/commit/caf57c3d50635c5869364c432de76ea791ddb751) little cleanup ### 📊 Changes **4 files changed** (+47 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spelling/allow/apis.txt` (+3 -0) 📝 `src/cascadia/WindowsTerminal/AppHost.cpp` (+6 -0) 📝 `src/cascadia/WindowsTerminal/IslandWindow.cpp` (+37 -0) 📝 `src/cascadia/WindowsTerminal/IslandWindow.h` (+1 -0) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:36:11 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29658