[PowerToys] Guard TitleBar windows against an empty window title (startup fault) - #49069
Merged
niels9001 merged 2 commits intoJul 2, 2026
Merged
Conversation
This was referenced Jul 1, 2026
… title-bar startup fault While reading through the Environment Variables window startup path I noticed the window title comes straight from ResourceLoader.GetString(...) with no fallback. ResourceLoader.GetString returns an empty string when the resource map can't be resolved at runtime, which leaves both Window.Title and the WinUI TitleBar control's Title empty. The WinUI TitleBar control reads the owning window's AppWindow.Title during a deferred layout pass. When the native window title is empty at that instant, the windowing layer can fault while resolving the title and terminate the process during startup. Guard the computed title with a non-empty product-name fallback so the native window title is always populated before the title bar reads it. The fallback is intentionally a plain string rather than a localized resource because it only runs when the resource loader itself failed to resolve. --- ADO: https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/62685601/ Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…dow title Follow-up to the Environment Variables fix in this PR: the same WinUI TitleBar startup fault applies to every window that hosts the TitleBar control with an extended title bar and can let the native window title be empty when the control first reads it during a deferred layout pass. Applied the same non-empty-title guard to the other affected windows: - Hosts, File Locksmith, Shortcut Guide, and Settings' shortcut-conflict window: their titles come from ResourceLoader.GetString(...), which returns an empty string when the resource map can't be resolved at runtime. Fall back to a non-empty product name. - Registry Preview: it only set AppWindow.Title later (in UpdateWindowTitle, on file load), leaving the native window title empty during startup. Set it to the app name in the constructor. Keyboard Manager Editor already sets a hardcoded non-empty Title, so it needs no change. Built each affected project (Hosts, FileLocksmithUI, ShortcutGuide.Ui, RegistryPreview, PowerToys.Settings) in Release x64 with no errors. --- ADO: https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/62685601/ Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
crutkas
force-pushed
the
user/crutkas/fix-envvars-titlebar-failfast
branch
from
July 1, 2026 19:05
4121a1e to
b9643f2
Compare
niels9001
enabled auto-merge (squash)
July 2, 2026 12:12
niels9001
approved these changes
Jul 2, 2026
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.
Summary
Guard PowerToys' WinUI windows against an empty native window title, so the WinUI
TitleBarcontrol can't read an empty title during startup and fault the process. This fixes a class of bugs like #48547Background
Spotted while reading through the Environment Variables
MainWindowstartup path. The WinUITitleBarcontrol (used withExtendsContentIntoTitleBar) reads the owning window'sAppWindow.Titleduring a deferred layout pass (OnApplyTemplate→UpdateTitle). When the native window title is empty at that instant, the windowing layer can fault while resolving the title and terminate the process during startup.The native title ends up empty in two ways:
ResourceLoader.GetString(...), which returns an empty string (it doesn't throw) when the resource map can't be resolved at runtime.AppWindow.Titleonly later, not before the title bar's first layout.Windows fixed
Every PowerToys window that hosts the
TitleBarcontrol:AppWindow.Titleto the app name in the constructor (previously only set later inUpdateWindowTitle)TitleRisk
Very low. The only behavior change is that a previously-empty title becomes a non-empty fallback; the normal (resource-resolved) paths are unchanged.
Validation
Each affected project builds clean (
x64 | Release): EnvironmentVariables, Hosts, FileLocksmithUI, ShortcutGuide.Ui, RegistryPreview, PowerToys.Settings.Related
Root cause write-up (windowing/WinUI side): microsoft/microsoft-ui-xaml#11214.
ADO: https://microsoft.visualstudio.com/DefaultCollection/OS/_workitems/edit/62685601/