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

[DRAFT] Re-add #9202, but with less crashes #10036

Closed

Conversation

skyline75489
Copy link
Collaborator

Summary of the Pull Request

Introduced by #9202, I mistakenly used the glyphStart instead of textStart to calculate the cluster map of simple runs, causing the application to crash when it hits N-M cluster maps. This PR corrects the mistake.

References

PR Checklist

  • Closes Terminal crashes when running git log #10034
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Documentation updated. If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated.
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

@ghost ghost added Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Terminal The new Windows Terminal. Severity-Crash Crashes are real bad news. labels May 5, 2021
@skyline75489 skyline75489 changed the title Fix glyph cluster crash caused by #9202 [WIP] Fix glyph cluster crash caused by #9202 May 5, 2021
@skyline75489
Copy link
Collaborator Author

OK I found more defects in #9202 and I'm marking this as WIP. I'm OK with reverting #9202 because this PR is not pretty...

CC and Requesting help from @miniksa

if (isTextSimple)
{
// Only copy the indices when the run is simple.
// Otherwise the glyph indices from GetTextComplexity are not meaningful.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is from the documentation of IDWriteTextAnalyzer1::GetTextComplexity

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Even with the fix, the _glyphIndices for simple runs will have wrong start index, if there's N-M runs previous to them. For example a simple line like this:

😀

There's two runs. First is complex, the second is simple.

Text Length Glyph Count
😀 2 1
(A lot of spaces 118 118

The correct _glyphIndices is this:

Index Value
0 11685
1 3
2 3
3 3
... ...

But here we have:

Index Value
0 11685
1 0
2 3
3 3
... ...

Notice there's an incorrect 0 indice here, because when we do GetTextComplexity on the second run, we have no idea how many glyphs the previous run takes up, and assume the number is equal to the textLength (2) and fill up the _glyphIndices from there.

while (indicesDiff > 0)
{
// Left shift the indices.
_glyphIndices.erase(_glyphIndices.begin() + glyphStart + actualGlyphCount);
Copy link
Collaborator Author

@skyline75489 skyline75489 May 5, 2021

Choose a reason for hiding this comment

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

This is me trying to fix the issue mentioned above by left-shifting the entire array to avoid vacancy in _glyphIndices.

@miniksa
Copy link
Member

miniksa commented May 5, 2021

If this is insufficient and doesn't fix the problems from #9202, then we need to revert it until we figure it out. I don't have the brain capacity to dive into this space this week. cc: @DHowett

@skyline75489
Copy link
Collaborator Author

This fixes the problems for #9202 (both crash & rendering issue) but I'm not confident that this is the proper way, or maybe this will leads to other unknown issues. So reverting #9202 might be a good option to unblock future releases.

@DHowett
Copy link
Member

DHowett commented May 11, 2021

For now I'll revert 9502. Sorry @skyline75489 😄

@DHowett
Copy link
Member

DHowett commented May 11, 2021

Sorry, 9202.

@zadjii-msft
Copy link
Member

Should we repurpose this issue as "re-add #9202, but with less crashes", or should we open a new PR for that? I don't really care which ¯\_(ツ)_/¯

@DHowett
Copy link
Member

DHowett commented May 12, 2021

Should we repurpose this issue as "re-add #9202, but with less crashes", or should we open a new PR for that? I don't really care which ¯_(ツ)_/¯

I'd like to repurpose it!

@skyline75489 skyline75489 marked this pull request as draft May 24, 2021 06:11
@skyline75489 skyline75489 changed the title [WIP] Fix glyph cluster crash caused by #9202 [DRAFT] Re-add #9202, but with less crashes May 24, 2021
@skyline75489
Copy link
Collaborator Author

Hey guys I've repurposed this. I realized that in order to fully solve this, we might need to rewrite the underlying run structure. Is the DxRenderer included in the TextBuffer rewrite of 2021? I think this is somewhat blocked by that.

@DHowett
Copy link
Member

DHowett commented May 25, 2021

It's not expected that the text buffer change will cause or require any changes in the renderer :) The interfaces through which the rest of the code reads the buffer are staying unchanged

@skyline75489
Copy link
Collaborator Author

Closed in favor of future work for #9156

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Terminal The new Windows Terminal. Severity-Crash Crashes are real bad news.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terminal crashes when running git log
4 participants