[PR #15161] Register the GetWindowLayoutRequested handler only when ready #30468

Closed
opened 2026-01-31 09:40:59 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/15161

State: closed
Merged: Yes


Moves our GetWindowLayoutRequested handler AFTER the xaml island is started. The AppHost::_GetWindowLayoutAsync handler requires us to be able to work on our UI thread, which requires that we have a Dispatcher ready for us to move to. If we set up this callback in the ctor, then it is possible for there to be a time slice where

  • the monarch creates the peasant for us,
  • we get ctor'ed (registering the callback)
  • then the monarch attempts to query all peasants for their layout, coming back to ask us even before XAML has been created.

I believe this was the source of the crash that was reported in a mail thread. It actually happened to me once while debugging another branch. Alas, this was realy hard to hit in the first place, so I'm not totally certain this fixes it.

Related to #14957

**Original Pull Request:** https://github.com/microsoft/terminal/pull/15161 **State:** closed **Merged:** Yes --- Moves our `GetWindowLayoutRequested` handler AFTER the xaml island is started. The `AppHost::_GetWindowLayoutAsync` handler requires us to be able to work on our UI thread, which requires that we have a `Dispatcher` ready for us to move to. If we set up this callback in the ctor, then it is possible for there to be a time slice where * the monarch creates the peasant for us, * we get ctor'ed (registering the callback) * then the monarch attempts to query all _peasants_ for their layout, coming back to ask us even before XAML has been created. I believe this was the source of the crash that was reported in a mail thread. It actually happened to me once while debugging another branch. Alas, this was realy hard to hit in the first place, so I'm not _totally_ certain this fixes it. Related to #14957
claunia added the pull-request label 2026-01-31 09:40:59 +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#30468