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

Fix a crash when resizing conhost in Debug #13001

Merged
merged 1 commit into from
Apr 29, 2022
Merged

Conversation

zadjii-msft
Copy link
Member

Don't clamp here, it's unnecessary. See notes in #12917 (comment)

Closes #12917

Don't clamp here, it's unnecessary. See notes in #12917 (comment)

Closes #12917
@ghost ghost added Area-Output Related to output processing (inserting text into buffer, retrieving buffer text, etc.) Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-0 Bugs that we consider release-blocking/recall-class (P0) Product-Conhost For issues in the Console codebase Severity-Crash Crashes are real bad news. labels Apr 29, 2022
@ghost
Copy link

ghost commented Apr 29, 2022

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

❌ zadjii-msft sign now
You have signed the CLA already but the status is still pending? Let us recheck it.

cursorView = view.Clamp(cursorView);

if (cursorView.IsValid())
if (view.IsInBounds(cursorView))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a strange way for us to do this. And IsInBounds doesn't beef? Neat!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the old way was strange.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's a bit late to tell you now, but I don't think this is right. I haven't had a chance to check, but I think IsInBounds is testing whether the whole cursorView is inside the view, but that means a cursor that is partially off screen is probably not going to be refreshed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmmmm..

Would this come up when the cursor is on a double-width glyph and the viewport is scrolled such that it cuts that glyph in half?

Copy link
Collaborator

@j4james j4james Apr 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Also on a double-width line, or even a double-width glyph on a double-width line, which can be four cells wide.

@DHowett DHowett merged commit 7990436 into main Apr 29, 2022
@DHowett DHowett deleted the dev/migrie/b/12917-clamp branch April 29, 2022 19:39
ghost pushed a commit that referenced this pull request Jan 11, 2023
Depending on the line rendition, and whether the cursor is over a wide
character or not, it's possible for the width to take up anywhere from 1
to 4 cells. And when it's more than 1 cell wide, part of the cursor may
end up off screen. However, our bounds check requires the entire cursor
to be on screen, otherwise it doesn't render anything, and that can
result in cursor droppings being left behind. This PR fixes that.

The bounds check that is causing this issue was introduced in #13001 to
fix a debug assertion.

To fix this, I've removed the bounds checking, and instead clip the
cursor rect to the boundaries of the viewport. This is what the original
code was trying to do prior to the #13001 fix, but was mistakenly using
the `Viewport:Clamp` method, instead of `TrimToViewport`. Since this
implementation doesn't require a clamp, there should be no risk of the
debug assertion returning.

## Validation Steps Performed

I've confirmed that the test case in #14657 is now working correctly,
and not leaving cursor droppings behind. I've also tested under conhost
with buffer sizes wider than the viewport, and confirmed it can handle a
wide cursor partially scrolled off screen.

Closes #14657
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Output Related to output processing (inserting text into buffer, retrieving buffer text, etc.) Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-0 Bugs that we consider release-blocking/recall-class (P0) Product-Conhost For issues in the Console codebase Severity-Crash Crashes are real bad news.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"invalid bounds arguments passed to std::clamp" when resizing window to zero height
3 participants