Repository navigation
Don't reload the UI when the keyboard layout changes - #14498
Mike Griese (zadjii-msft) wants to merge 6 commits into
Conversation
Carlos Zamora (carlos-zamora)
left a comment
There was a problem hiding this comment.
I mean, I don't mind this solution. If anything, I bet there's a few other scenarios we want to apply the exact same thing to.
| // - Reloads the settings from the settings.json file. | ||
| void AppLogic::_ReloadSettings() | ||
| void AppLogic::_ReloadSettings(const bool keybindingsOnly) |
There was a problem hiding this comment.
nits...
- update method description
- I'd rename this
needRefreshUIor something similar just to make it more general
|
You know, one of the things that weirds me out about this is that we don't need to reload the settings at all... just re-apply their effects. Would it be possible to only reprocess the key bindings from the original model objects? That would address the bulk of the issue and make for a more targeted fix... |
Dustin L. Howett (DHowett)
left a comment
There was a problem hiding this comment.
(Per discussion, not sure this is the right solution -- we may benefit from iterating further!)
Leonard Hecker (@lhecker) might need to back me up on this - could we just call Now that I'm re-reading |
|
|
|
Hmm. Updating the Not sure what there is to do here. I can try to look if there's a way to build a fresh Settings object and just steal the actions map? Maybe that would work? |
|
I could theoretically make changes to
Does that seem like it's sensible? How egregious of a layering violation does that feel like? |
|
I think this is the problem:
The thing consuming the settings model object here should be on the hook for this. If we made that change, would it be easier to do "reevaluate all SC/VK" as a follow-on? |
|
(Feel free to veto me) |
|
This is super stale. Like 1.5 years is too long, and there have been major rewrites since. We need to surely just start fresh |
Standalone investigation branch for microsoft#11522. Not intended for upstream merge. Instrumentation (AppLogic.cpp): - Log every LanguageProfileNotifier OnActivated firing with process memory snapshots (priv/ws) via OutputDebugString and TraceLogging under the existing Microsoft.Windows.Terminal.App provider. - Time the full SettingsChanged.raise() path, which synchronously runs TerminalPage::_RefreshUIForSettingsReload and is responsible for the multi-second UI freeze observed on layout switch. - Add WT_GH11522_SKIP environment variable: when set to any value, suppresses the ReloadSettingsThrottled() call in the callback so A/B comparison against the default reload path is possible without rebuilding. Reproducer (stress-tab.ps1): - PowerShell script that fills a new tab with 10 000 lines of URL-ish scrollback content to exercise ControlCore::UpdatePatternLocations under the same til::ticket_lock that _RefreshUIForSettingsReload competes with during per-tab UpdateSettings propagation. - Used with: 1..40 | ForEach-Object { wtd -w 0 nt powershell -NoExit -File <path>\stress-tab.ps1 Start-Sleep -Milliseconds 150 } to produce ~1.1-1.5 GB private-bytes stressed state in under a minute instead of waiting days for natural accumulation. Writeup (wt-keyboard-layout-lag-investigation.md): - Full root-cause call-chain walkthrough - Empirical measurements: ~3.5 s per reload at stressed state, +329/+633 MB private-bytes delta on first reload after state change, zero lag and stable memory with WT_GH11522_SKIP=1 - Additional finding on ThrottledFunc double-reload under rapid events (9 layout events -> 2 back-to-back reloads, 7.2 s total freeze) - Connection between the lag and the 8.78 GB host-process memory bloat - Upstream status and prior art (microsoft#14498, microsoft#19933) - Three escalating tiers of what a proper fix could look like Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Alrighty, this is a silly solution to the problem. Go read #11522.
What if, we just didn't reload the UI for a settings reload?
Terminal refreshes the appearance of panes, profiles, tabs, etc, in
TerminalPage::_RefreshUIForSettingsReload. That's only called inTerminalPage::SetSettings, when we specify that we didn't need to reload the UI. Currently, we only don't reload the UI on an initial load of the settings (that makes sense, there's no UI to "reload" yet.)So what if we did all of
TerminalPage::SetSettings, but without the UI reload? We update the keybindings, the command palette, the current language, but not the actual content of the tabs.before
after
Closes #11522?
A caveat from discussion:
This might have some weird irreproducible bugs in it. Consider
Both these windows will reload the settings, find that the new settings (& dynamic profile) are different, and will try to write the settings to the disk. One will win? Maybe? Both will probably end up with a full UI refresh, for determining that the settings file changed.
But is this fine anyways? We're pretty sure there's a backlog item for "reload the settings on a distro install" anyways. And the value add of this fix is probably worth more than the very rare new edge case where this still happens.