Skip to content

TitleBar: avoid AppWindow.Title() getter reads that can fail-fast the process (#11214) - #11215

Draft
crutkas wants to merge 2 commits into
microsoft:mainfrom
crutkas:user/crutkas/titlebar-avoid-appwindow-title-read
Draft

TitleBar: avoid AppWindow.Title() getter reads that can fail-fast the process (#11214)#11215
crutkas wants to merge 2 commits into
microsoft:mainfrom
crutkas:user/crutkas/titlebar-avoid-appwindow-title-read

Conversation

@crutkas

@crutkas crutkas commented Jul 1, 2026

Copy link
Copy Markdown
Member

Draft / discussion — a WinUI-side mitigation for #11214. Not yet built/validated locally; opening to discuss the approach.

Problem

TitleBar::UpdateTitle and TitleBar::ResetTitle read back AppWindow.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 an E_INVALIDARG (0x80070057) fail-fast. Full root cause in #11214.

A try/catch in 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: set AppWindow.Title unconditionally; stop reading it back (removes both the default-capture read and the redundant-set read).
  • ResetTitle: no longer reads AppWindow.Title, and no longer auto-restores a previously-captured window title.
  • Remove the now-unused m_defaultAppWindowTitle / m_hasDefaultAppWindowTitle members.

Tradeoff (why this is a draft)

This drops the automatic "restore the window's original title when TitleBar.Title is cleared" behavior. Apps that relied on it would set Window.Title / AppWindow.Title themselves.

The preferred fix is in the windowing layer — make the AppWindow.Title getter treat an empty title as valid (it's a wrapper over GetWindowTextLengthW, 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

crutkas and others added 2 commits July 1, 2026 11:03
… 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>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the needs-triage Issue needs to be triaged by the area owners label Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-triage Issue needs to be triaged by the area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant