-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
AtlasEngine: Harden against empty target sizes #15615
AtlasEngine: Harden against empty target sizes #15615
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it did not :D
How do you test this? With WpfTerminalTestNetCore? I can't reproduce any issues to begin with... |
it is dangerous to go alone. take this! https://github.com/microsoft/terminal/tree/dev/duhowett/hax/wpf-atlas |
d4cccea
to
626cdb3
Compare
96d0c3c
to
721dc99
Compare
gsl::narrow_cast<u16>(clamp<til::CoordType>(pixels.height, 1, u16max)), | ||
}; | ||
|
||
if (_api.s->targetSize != newSize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR now fixes the issue from two directions:
- Avoid ever setting
targetSize
to anything that has a 0 on either width or height
const auto area = std::min(maxArea, std::min(maxAreaByFont, min)); | ||
|
||
auto area = std::min(maxAreaByFont, std::max(minAreaByFont, minAreaByGrowth)); | ||
area = clamp(area, minArea, maxArea); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Avoid reducing
area
belowminArea
at all times
(minArea
should probably be called absoluteMinArea
or something.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it! Please update the body as well, since it's got a question mark emoji in it
The WPF control has a minor bug where it initializes the renderer when there isn't even a window yet. When it then calls `SetWindowSize` it'll pass the result of `GetWindowRect` which is `0,0,0,0`. This made AtlasEngine unhappy because it restricted the glyph atlas size to some multiple of the window size. If the window size is `0,0` then there couldn't be a glyph atlas and so it crashed. ## Validation Steps Performed * Fixes WPF test control crash on startup ✅ (cherry picked from commit a084834) Service-Card-Id: 90012548 Service-Version: 1.18
The WPF control has a minor bug where it initializes the renderer
when there isn't even a window yet. When it then calls
SetWindowSize
it'll pass the result of
GetWindowRect
which is0,0,0,0
.This made AtlasEngine unhappy because it restricted the glyph atlas
size to some multiple of the window size. If the window size is
0,0
then there couldn't be a glyph atlas and so it crashed.
Validation Steps Performed