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

Extremely lower performance when displaying too many box-shading glyphs #6974

Closed
HO-COOH opened this issue Jul 19, 2020 · 9 comments · Fixed by #14959
Closed

Extremely lower performance when displaying too many box-shading glyphs #6974

HO-COOH opened this issue Jul 19, 2020 · 9 comments · Fixed by #14959
Assignees
Labels
Area-Performance Performance-related issue Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Help Wanted We encourage anyone to jump in on these. In-PR This issue has a related PR Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.

Comments

@HO-COOH
Copy link
Contributor

HO-COOH commented Jul 19, 2020

Environment

Windows build number: 19619
Windows Terminal version (if applicable): 1.0.1811.0

Any other software? No

Steps to reproduce

  1. Use WriteConsoleOutputW function to fill console with block characters and random foreground colors.

Expected behavior

Smooth and high performance

Actual behavior

  1. The new windows terminal performs very bad (same with powershell or cmd), only refreshing at a few fps. While the old terminal can easily get to a few hundred.
  2. And selecting the filled area after that is very laggy in new windows terminal, but it's very smooth in old windows console. See my gifs below.
    new_terminal
    old_terminal
@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 Jul 19, 2020
@zadjii-msft
Copy link
Member

Huh, that's bizarre.

select-rgb

Maybe there's something odd about your hardware that's causing this. The Terminal and the vintage console use different rendering stacks, so it's possible that the newer DX features the Terminal is using don't work as nicely on your machine.

@zadjii-msft zadjii-msft added Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Product-Terminal The new Windows Terminal. labels Jul 20, 2020
@HO-COOH
Copy link
Contributor Author

HO-COOH commented Jul 20, 2020

@zadjii-msft
I am using an AMD gpu and the latest stable driver and FreeSync is not enabled.
Setting experimental.rendering.forceFullRepaint to false and experimental.rendering.software to true I get a slight smoothness improvement, but significantly higher CPU usage, still nowhere as close to the old console.
I noticed this character specifically causes the slow down
░░░ <- This is the character, which is a wchar_t, code 0x2592

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jul 20, 2020
@HO-COOH
Copy link
Contributor Author

HO-COOH commented Jul 20, 2020

Yes, can confirm. If you compile this C++ under windows and run it with old and new console, you will see the huge difference.

#include <iostream>
int main()
{
    char c[] = "";
    for (int i = 0; i < 5000; ++i)
        std::cout << c;
}

vs

@DHowett
Copy link
Member

DHowett commented Jul 20, 2020

This is probably because of the separate rendering pass for box drawing glyphs. @miniksa might be interested in the pathological test case.

@DHowett DHowett added the Area-Performance Performance-related issue label Jul 20, 2020
@DHowett DHowett changed the title Extremely lower performance when using native WIN32API to fill colored text compared to old console Extremely lower performance when displaying too many box-shading glyphs Jul 20, 2020
@miniksa
Copy link
Member

miniksa commented Jul 20, 2020

This is probably because of the separate rendering pass for box drawing glyphs. @miniksa might be interested in the pathological test case.

Man, I just can't make everyone happy, now can I? :P

There's probably something I can do here to not recalc every scale or something. I'll dig.

@miniksa miniksa self-assigned this Jul 20, 2020
@DHowett DHowett added this to the Terminal v2.0 milestone Jul 20, 2020
@DHowett DHowett added Issue-Bug It either shouldn't be doing this or needs an investigation. and removed Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jul 20, 2020
@schorrm
Copy link
Contributor

schorrm commented Aug 7, 2020

I don't think the scaling is breaking this. It seems to show up as just the one GlyphRun.

@magiblot
Copy link

This makes certain text-based applications nearly unusable:

2021-05-28.00-07-50.mp4

That separate rendering pass for box-drawing glyphs @DHowett mentioned, can it be disabled? I don't know if it's related to this, but in my opinion box-drawing characters look notably uglier in Terminal than in Conhost (for example, the background dot grid in the video above).

electroly added a commit to tmbasic-lang/tmbasic that referenced this issue May 29, 2021
@zadjii-msft zadjii-msft added the Priority-2 A description (P2) label Jul 15, 2021
@zadjii-msft zadjii-msft modified the milestones: Terminal v2.0, 22H1 Jan 4, 2022
@zadjii-msft zadjii-msft added the Help Wanted We encourage anyone to jump in on these. label Jan 4, 2022
@zadjii-msft zadjii-msft modified the milestones: 22H1, Terminal v1.14 Feb 2, 2022
@lhecker
Copy link
Member

lhecker commented Feb 4, 2022

If anyone would like to do so, please feel free to try out the new rendering engine we just released today:
https://devblogs.microsoft.com/commandline/windows-terminal-preview-1-13-release/#new-rendering-engine

Unfortunately we made a mistake during packaging, due to which this version was released with English translations only, but I expect this issue to be resolved soon.

In either case: While we haven't specifically tested the new renderer for proper box character drawing yet, it's performance is inherently unaffected by the kind of content you're drawing. As such box character drawing backgrounds now look like this:

NL6uL25ugufkPPpt.mp4

@miniksa
Copy link
Member

miniksa commented Feb 5, 2022

FWIW #12375 will bring the languages back and should be deployed early next week. It just took until EOD Friday to figure out what to do... and we're not shipping anything on a Friday.

@zadjii-msft zadjii-msft modified the milestones: Terminal v1.14, 22H1 Mar 10, 2022
@zadjii-msft zadjii-msft modified the milestones: 22H1, EIM Summer 2022 Jun 13, 2022
@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR This issue has a related PR label Apr 7, 2023
microsoft-github-policy-service bot pushed a commit that referenced this issue Apr 26, 2023
This is practically a from scratch rewrite of AtlasEngine.

The initial approach used a very classic monospace text renderer, where
the viewport is subdivided into cells and each cell is assigned one
glyph texture, just like how real terminals used to work.
While we knew that it would have problems with overly large glyphs,
like those found in less often used languages, we didn't expect the
absolutely massive number of fonts that this approach would break.
For one, the assumption that monospace fonts are actually mostly
monospace has turned out to be a complete lie and we can't force users
to use better designed fonts. But more importantly, we can't just
design an entire Unicode fallback font collection from scratch where
every major glyph is monospace either. This is especially problematic
for vertical overhangs which are extremely difficult to handle in a
way that outperforms the much simpler alternative approach:
Just implementing a bog-standard, modern, quad-based text renderer.

Such an approach is both, less code and runs faster due to a less
complex CPU-side. The text shaping engine (in our case DirectWrite)
has to resolve text into glyph indices anyways, so using them directly
for text rendering allows reduces the effort of turning it back into
text ranges and hashing those. It's memory overhead is also reduced,
because we can now break up long ligatures into their individual glyphs.
Especially on AMD APUs I found this approach to run much faster.

A list of issues I think are either obsolete (and could be closed)
or resolved with this PR in combination with #14255:

Closes #6864
Closes #6974
Closes #8993
Closes #9940
Closes #10128
Closes #12537
Closes #13064
Closes #13527
Closes #13662
Closes #13700
Closes #13989
Closes #14022
Closes #14057
Closes #14094
Closes #14098
Closes #14117
Closes #14533
Closes #14877

## PR Checklist
* Enabling software rendering enables D2D mode ✅
* Both D2D and D3D:
  * Background appears correctly ✅✅
  * Text appears correctly
    * Cascadia Code Regular ✅✅
    * Cascadia Code Bold ✅✅
    * Cascadia Code Italic ✅✅
    * Cascadia Code block chars leave (almost) no gaps ✅✅
    * Terminus TTF at 13.5pt leaves no gaps between block chars ✅✅
    * ``"`u{e0b2}`u{e0b0}"`` in Fira Code Nerd Font forms a square ✅✅
  * Cursor appears correctly
    * Legacy small/medium/large ✅✅
    * Vertical bar ✅✅
    * Underscore ✅✅
    * Empty box ✅✅
    * Full box ✅✅
    * Double underscore ✅✅
  * Changing the cursor color works ✅✅
  * Selection appears correctly ✅✅
  * Scrolling in various manners always renders correctly ✅✅
  * Changing the text antialising mode works ✅✅
  * Semi-transparent backgrounds work ✅✅
  * Scroll-zooming the font size works ✅✅
  * Double-size characters work ✅✅
  * Resizing while text is printing works ✅✅
  * DWM `+Heatmap_ShowDirtyRegions` shows that only the cursor
    region is dirty when it's blinking ✅✅
* D2D
  * Margins are filled with background color ❌
    They're filled with the neighboring's cell background color for
    convenience, as D2D doesn't support `D3D11_TEXTURE_ADDRESS_BORDER`
* D3D
  * Margins are filled with background color ✅
  * Soft fonts work ✅
  * Custom shaders enable continous redraw if time constant is used ✅
  * Retro shader appears correctly ✅
  * Resizing while a custom shader is running works ✅
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Performance Performance-related issue Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Help Wanted We encourage anyone to jump in on these. In-PR This issue has a related PR Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants