Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Crash on window resize #2277

Closed
kfarmer-msft opened this issue Aug 6, 2019 · 21 comments · Fixed by #3181 or #3832
Closed

BUG: Crash on window resize #2277

kfarmer-msft opened this issue Aug 6, 2019 · 21 comments · Fixed by #3181 or #3832
Labels
Area-Quality Stability, Performance, Etc. Area-User Interface Issues pertaining to the user interface of the Console or Terminal Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. Severity-Crash Crashes are real bad news. Tracking-External This bug isn't resolved, but it's following an external workitem.
Milestone

Comments

@kfarmer-msft
Copy link

kfarmer-msft commented Aug 6, 2019

Environment

Windows build number: 
Microsoft Windows [Version 10.0.18362.267]

Windows Terminal version (if applicable):
Windows Terminal (Preview)
Version: 0.3.2142.0

Any other software?
None

Steps to reproduce

Start terminal. Resize. I pretty consistently get a crash when I get to about the point of the single tab going to zero width.

Start terminal. Add multiple tabs. Resize. I get crashes when the third tab starts to slide under the new tab UI.

Sometimes you can shrink all the way down and back. Sometimes you can shrink all the way down, and it'll crash as it is being expanded.

Expected behavior

Window resizes without crash

Actual behavior

Here's one of the entries from my event log.

Faulting application name: WindowsTerminal.exe, version: 1.0.1908.2002, time stamp: 0x5d448424
Faulting module name: Windows.UI.Xaml.dll, version: 10.0.18362.267, time stamp: 0x3e916038
Exception code: 0xc000027b
Fault offset: 0x00000000007126f0
Faulting process id: 0x2fa8
Faulting application start time: 0x01d54c269fed96bb
Faulting application path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.3.2142.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe
Faulting module path: C:\Windows\System32\Windows.UI.Xaml.dll
Report Id: 985f1c17-14dc-45a2-9bf2-2e663574efa9
Faulting package full name: Microsoft.WindowsTerminal_0.3.2142.0_x64__8wekyb3d8bbwe
Faulting package-relative application ID: App

Here's the feedback hub entry, which should have dx attached to it:

https://aka.ms/AA5roli

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Aug 6, 2019
@zadjii-msft zadjii-msft added Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. Severity-Crash Crashes are real bad news. labels Aug 6, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Aug 6, 2019
@zadjii-msft zadjii-msft added this to the Terminal 1908.1 milestone Aug 6, 2019
@dpuza-formativ
Copy link

I came here to post this since this immediately happened to me, and is repeatable. Guess I'm not the only one.

@DHowett-MSFT DHowett-MSFT added Help Wanted We encourage anyone to jump in on these. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Aug 8, 2019
@olepalm
Copy link

olepalm commented Aug 9, 2019

On my system, the crash occurs if the width the terminal window < ~850px, no matter the amount of tabs. This is with 150% display scaling in display options.

The height of the window seems to have no impact on stability.

@jazzdelightsme
Copy link
Member

Terminal people: the error is AG_E_LAYOUT_CYCLE, coming from Windows_UI_Xaml!CLayoutManager::UpdateLayout. That function has a while loop where it does layout, and keeps looping around while the tree is dirty (like something changed size or somesuch), until it hits some arbitrary limit, at which point it throws up its hands with this error.

Perhaps the terminal is adjusting the size of something in response to some size-changed event, and we get into a state where we're oscillating or something like that.

@jghal
Copy link

jghal commented Nov 11, 2019

Not sure if I will be able to do a build myself to test. We haven't officially rolled out 1903 internally, so I had upgrade my laptop and dev VM, and of course Terminal is working out of the box on the dev VM, but other software is not working with 1903 so IT is on track to destroy and redploy the VM with 1803. So while I may be able to get the dev tools setup and build from master on the VM before they do that, it wouldn't really serve to validate the fix since Terminal works there.

If you're hitting this super consistently, you might be able to set tabTitle to something other than "Windows Powershell" and have this go away magically.

Consistently crashes on launch, draws a window frame but I never see the terminal application actually load inside it, and the window just goes away after a few seconds. I just tried playing with setting tabTitle on every profile, and cycled through every profile as the defaultProfile, no luck.

{
    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",

    "profiles":
    [
        {
            "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
            "name": "Windows PowerShell",
            "commandline": "powershell.exe",
            "hidden": false,
            "tabTitle": "PWSH"
        },
        {
            "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
            "name": "cmd",
            "commandline": "cmd.exe",
            "hidden": false,
            "tabTitle": "CMD"
        },
        {
            "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
            "hidden": false,
            "name": "PowerShell Core",
            "source": "Windows.Terminal.PowershellCore",
            "tabTitle": "PWSH Core"
        },
        {
            "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
            "hidden": false,
            "name": "Ubuntu",
            "source": "Windows.Terminal.Wsl",
            "tabTitle": "WSL"
        },
        {
            "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
            "hidden": true,
            "name": "Azure Cloud Shell",
            "source": "Windows.Terminal.Azure",
            "tabTitle": "AZSH"
        }
    ],

    "schemes": [],

    "keybindings": []
}

I also noticed above this error is also reported for font sizes smaller than 10 so I tried adding "fontSize": 12 to all profiles, still no luck.

@zadjii-msft
Copy link
Member

Hey everyone, just an update here:

I've dug real deep into XAML over the last week, and working with @teaP, we were able to find that the source of the E_LAYOUTCYCLE wasn't coming from the Windows Terminal code, it was coming from the TabView code itself. Fortunately, @teaP has whipped up a fix for us, which should be available on the next update of Microsoft.UI.Xaml 🎉.

At the time of writing it's unclear when we'll ingest that update and push an update to the store. We'll keep you posted in this thread when we know more. Thanks all for help with getting repro steps found!

@zadjii-msft zadjii-msft added Tracking-External This bug isn't resolved, but it's following an external workitem. and removed Needs-Repro We can't figure out how to make this happen. Please help find a simplified repro. labels Nov 26, 2019
@jghal
Copy link

jghal commented Dec 2, 2019

For me the crash on launch has been resolved in the released 0.7.3291.0 build. 😄

@flickerfly
Copy link

True, it doesn't crash when I move between windows now, but if I then maximize it, it immediately crashes. As before, if I open a second tab before maximizing, it does not crash.

Not yet resolved, but getting better.

@ghost ghost added the In-PR This issue has a related PR label Dec 4, 2019
@ghost ghost closed this as completed in #3832 Dec 4, 2019
ghost pushed a commit that referenced this issue Dec 4, 2019
## Summary of the Pull Request

Updates MUX to the latest pre-release version. This prerelease has a fix for a certain `E_LAYOUTCYCLE` bug in the TabView that was causing an untold number of crashes for us.

Thanks again @teaP!

## PR Checklist
* [x] Closes #3303
* [x] Closes #2277
* [x] I work here
* [n/a] Tests added/passed
* [n/a] Requires documentation to be updated
DHowett-MSFT pushed a commit that referenced this issue Dec 4, 2019
Updates MUX to the latest pre-release version. This prerelease has a fix for a certain `E_LAYOUTCYCLE` bug in the TabView that was causing an untold number of crashes for us.

Thanks again @teaP!

* [x] Closes #3303
* [x] Closes #2277
* [x] I work here
* [n/a] Tests added/passed
* [n/a] Requires documentation to be updated

(cherry picked from commit 2f0abc2)
@ghost
Copy link

ghost commented Dec 6, 2019

🎉This issue was addressed in #3832, which has now been successfully released as Windows Terminal Preview v0.7.3382.0.:tada:

Handy links:

DHowett-MSFT pushed a commit that referenced this issue Jan 8, 2020
When user resizes window, snap the size to align with the character grid
(like e.g. putty, mintty and most unix terminals). Properly resolves
arbitrary pane configuration (even with different font sizes and
padding) trying to align each pane as close as possible.

It also fixes terminal minimum size enforcement which was not quite well
handled, especially with multiple panes.

This PR does not however try to keep the terminals aligned at other user
actions (e.g. font change or pane split). That is to be tracked by some
other activity.

Snapping is resolved in the pane tree, recursively, so it (hopefully)
works for any possible layout.

Along the way I had to clean up some things as so to make the resulting
code not so cumbersome:
1. Pane.cpp: Replaced _firstPercent and _secondPercent with single
   _desiredSplitPosition to reduce invariants - these had to be kept in
   sync so their sum always gives 1 (and were not really a percent). The
   desired part refers to fact that since panes are aligned, there is
   usually some deviation from that ratio.
2. Pane.cpp: Fixed _GetMinSize() - it was improperly accounting for
   split direction
3. TerminalControl: Made dedicated member for padding instead of
   reading it from a control itself. This is because the winrt property
   functions turned out to be slow and this algorithm needs to access it
   many times. I also cached scrollbar width for the same reason.
4. AppHost: Moved window to client size resolution to virtual method,
   where IslandWindow and NonClientIslandWindow have their own
   implementations (as opposite to pointer casting).

One problem with current implementation is I had to make a long call
chain from the window that requests snapping to the (root) pane that
implements it: IslandWindow -> AppHost's callback -> App ->
TerminalPage -> Tab -> Pane. I don't know if this can be done better.

## Validation Steps Performed
Spam split pane buttons, randomly change font sizes with ctrl+mouse
wheel and drag the window back and forth.

Closes #2834
Closes #2277
@ghost ghost added Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed In-PR This issue has a related PR labels Jan 8, 2020
@ghost
Copy link

ghost commented Jan 14, 2020

🎉This issue was addressed in #3181, which has now been successfully released as Windows Terminal Preview v0.8.10091.0.:tada:

Handy links:

@fevernova90
Copy link

This keeps happening without failure when I am :

  • Resizing Windows Terminal which contains at least three Ubuntu 20.04 LTS (for my case) terminal in it horizontally and vertically.
  • Opening a new tab when the existing Ubuntu terminal has been running several commands for quite some time.

Version

Windows Terminal 1.0.1811.0
Windows Terminal Preview 1.1.1812.0

Screenshot

windows_terminal_resizing_bug

@zadjii-msft
Copy link
Member

@fevernova90 That looks like a new crash to me - would you mind filing a new issue for it? I don't want to muddle up this existing thread with a new crash who's source might be unrelated to the original. Thanks!

@fevernova90
Copy link

@zadjii-msft I have figured out the cause of the my Windows Terminal crashing with multiple tabs after seeing the event logs.

There's one app that hooked up into Windows Terminal, it is RivaTuner Statistics Server (which comes bundled when you installed MSI Afterburner).
RivaTuner may have detected that Windows Terminal is a full screen application and try to display hardware statistics in it.

I guess this issue is not relevant to everyone who does not tinkering with their GPU using MSI Afterburner.

Pasting my log here for info

Faulting application path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_1.0.1811.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe
Faulting module path: C:\Program Files (x86)\RivaTuner Statistics Server\RTSSHooks64.dll
Report Id: 2ce30154-a6d4-4db0-9d6d-21f916c290a5
Faulting package full name: Microsoft.WindowsTerminal_1.0.1811.0_x64__8wekyb3d8bbwe
Faulting package-relative application ID: App

@zadjii-msft
Copy link
Member

Ah, that makes sense. We've seen a few crashes like that with people using RivaTuner before. Thanks for following up!

@sina-salahshour
Copy link

my terminal is not opening at all, and the faulting module is Windows.UI.Xaml.dll.
os: windows 11 pro N
i also tried the preview version but there was no luck.

https://aka.ms/AAi9we7

@zadjii
Copy link

zadjii commented Oct 6, 2022

@sina-salahshour that is totally unrelated to this thread. There are other, more recent discussions on the topic - go install the media feature pack as a workaround

@sina-salahshour
Copy link

@zadjii #3381 was closed as a duplicate of this issue

@zadjii-msft
Copy link
Member

It's actually not #3381 either. Both these threads are multiple years old now.

What you're seeing is tracked in #14104.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Quality Stability, Performance, Etc. Area-User Interface Issues pertaining to the user interface of the Console or Terminal Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. Severity-Crash Crashes are real bad news. Tracking-External This bug isn't resolved, but it's following an external workitem.
Projects
None yet