TitleBar: avoid AppWindow.Title() getter reads that can fail-fast the process (#11214) - #11215
Draft
crutkas wants to merge 2 commits into
Draft
TitleBar: avoid AppWindow.Title() getter reads that can fail-fast the process (#11214)#11215crutkas wants to merge 2 commits into
crutkas wants to merge 2 commits into
Conversation
… GetTitle fail-fast (microsoft#11214) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… GetTitle fail-fast (microsoft#11214) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
TitleBar::UpdateTitleandTitleBar::ResetTitleread backAppWindow.Title(three getter calls) to capture/restore a "default" window title and to skip redundant sets. During a deferred layout pass at startup, that getter can fault inside the windowing layer when the native window title is momentarily empty, terminating the process with anE_INVALIDARG (0x80070057)fail-fast. Full root cause in #11214.A
try/catchin the control cannot help here — the failure is a fail-fast inside the windowing callee, not a returnable HRESULT — so the only WinUI-side mitigation is to not perform the getter reads.Change
UpdateTitle: setAppWindow.Titleunconditionally; stop reading it back (removes both the default-capture read and the redundant-set read).ResetTitle: no longer readsAppWindow.Title, and no longer auto-restores a previously-captured window title.m_defaultAppWindowTitle/m_hasDefaultAppWindowTitlemembers.Tradeoff (why this is a draft)
This drops the automatic "restore the window's original title when
TitleBar.Titleis cleared" behavior. Apps that relied on it would setWindow.Title/AppWindow.Titlethemselves.The preferred fix is in the windowing layer — make the
AppWindow.Titlegetter treat an empty title as valid (it's a wrapper overGetWindowTextLengthW, which returns 0 for an empty title and does not reset the last-error). This PR is a middle-layer mitigation for discussion: should WinUI take it in the meantime, or rely solely on the platform fix?Related app-side workaround: microsoft/PowerToys#49069.
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com