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

Resizing while alt buffer is active, then disabling it, blows away renderer #13038

Closed
DHowett opened this issue May 4, 2022 · 6 comments · Fixed by #13039
Closed

Resizing while alt buffer is active, then disabling it, blows away renderer #13038

DHowett opened this issue May 4, 2022 · 6 comments · Fixed by #13039
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Priority-1 A description (P1) 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.

Comments

@DHowett
Copy link
Member

DHowett commented May 4, 2022

  1. WSL, in a small window
  2. vim -u NONE
  3. Maximize the window
  4. Esc :q Enter
  5. Observe the window get "stuck" on vim

It looks like we're failing to render a dirty region that is outside of the new, smaller main buffer.

It appears as though Terminal is not resizing the main buffer, as it believes it is already the correct size.

That check is happening here:

const auto oldDimensions = _GetMutableViewport().Dimensions();
if (viewportSize == oldDimensions)
{
return S_FALSE;
}

At the time of failure, _GetMutableViewport returns _mutableViewport, since we are no longer in the alt buffer.

Setting a write breakpoint on _mutableViewport to determine who is setting it, it's coming from EraseAll -> SetViewportPosition:

void Terminal::SetViewportPosition(const til::point position)
{
const auto dimensions = _GetMutableViewport().Dimensions();
_mutableViewport = Viewport::FromDimensions(position.to_win32_coord(), dimensions);
Terminal::_NotifyScrollEvent();
}

Potentially regressed in #13024 (/cc @j4james)

@DHowett DHowett added Product-Conhost For issues in the Console codebase Issue-Bug It either shouldn't be doing this or needs an investigation. Severity-Crash Crashes are real bad news. Priority-2 A description (P2) labels May 4, 2022
@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 May 4, 2022
@DHowett DHowett added Product-Terminal The new Windows Terminal. Priority-0 Bugs that we consider release-blocking/recall-class (P0) Priority-1 A description (P1) Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) and removed Product-Conhost For issues in the Console codebase Priority-2 A description (P2) Priority-0 Bugs that we consider release-blocking/recall-class (P0) labels May 4, 2022
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label May 4, 2022
@j4james
Copy link
Collaborator

j4james commented May 4, 2022

Yeah, it's definitely regressed in #13024. I remember thinking at the time that the assignment to _mutableViewport looked suspicious, but I got that from the original "EraseAll" implementation here:

// Move the viewport, adjust the scroll bar if needed, and restore the old cursor position
_mutableViewport = Viewport::FromExclusive(newWin);
Terminal::_NotifyScrollEvent();

So I'm not sure why that worked before. There must be something else different between the conhost and terminal architectures. I'll do some digging.

@j4james
Copy link
Collaborator

j4james commented May 4, 2022

OK, I see now why it worked before. The terminal "EraseAll" implementation had an early exit check for _inAltBuffer() which meant the viewport wouldn't be set at all. But I think that's one of those things that only worked in Terminal because conpty would redraw the whole screen afterwards anyway. It's not actually clearing the screen in that case, so we can't do that in the current implementation.

@j4james
Copy link
Collaborator

j4james commented May 4, 2022

But now that I think about it we can just make the Terminal::SetViewportPosition method a no-op when in the alt buffer - that should fix it.

@DHowett
Copy link
Member Author

DHowett commented May 4, 2022

That makes sense to me. The viewport in the alt buffer is always the entire buffer, right?

@j4james
Copy link
Collaborator

j4james commented May 5, 2022

Yeah, if you look at the _GetMutableViewport method, it's just returning a Viewport object with the alt buffer dimensions, so it's always at 0,0.

Viewport Terminal::_GetMutableViewport() const noexcept
{
// GH#3493: if we're in the alt buffer, then it's possible that the mutable
// viewport's size hasn't been updated yet. In that case, use the
// temporarily stashed _altBufferSize instead.
return _inAltBuffer() ? Viewport::FromDimensions(_altBufferSize.to_win32_coord()) :
_mutableViewport;
}

@ghost ghost added the In-PR This issue has a related PR label May 5, 2022
@ghost ghost closed this as completed in #13039 May 5, 2022
@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 May 5, 2022
ghost pushed a commit that referenced this issue May 5, 2022
## Summary of the Pull Request

When `TerminalDispatch` was merged with `AdaptDispatch` in PR #13024,
that broke the Terminal's `EraseAll` operation in the alt buffer. The
problem was that the `EraseAll` implementation makes a call to
`SetViewportPosition` which wasn't taking the alt buffer into account,
and thus modified the main viewport instead.

This PR corrects that mistake. If we're in the alt buffer, the
`SetViewportPosition` method now does nothing, since the alt buffer
viewport should always be at 0,0.

## References

This was a regression introduced in PR #13024.

## PR Checklist
* [x] Closes #13038
* [x] CLA signed.
* [ ] Tests added/passed
* [ ] Documentation updated.
* [ ] Schema updated.
* [x] I've discussed this with core contributors already. Issue number where discussion took place: #13038

## Validation Steps Performed

I've confirmed that the test case reported in issue #13038 is no longer
failing. I've also made sure the `ED 2` and `ED 3` sequences are still
working correctly in the main buffer.
@ghost
Copy link

ghost commented May 24, 2022

🎉This issue was addressed in #13039, which has now been successfully released as Windows Terminal Preview v1.14.143.:tada:

Handy links:

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Priority-1 A description (P1) 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants