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

Startup and canvas render window resize that updates devicePixelRatio is expensive #955

Closed
Tyriar opened this issue Sep 8, 2017 · 10 comments
Labels
area/performance type/enhancement Features or improvements to existing features
Milestone

Comments

@Tyriar
Copy link
Member

Tyriar commented Sep 8, 2017

After #938

Repro:

  1. Launch xterm.js

  1. Open demo
  2. Start performance timeline
  3. Press cmd/ctrl and + 3 times

screen shot 2017-09-07 at 9 57 09 am

The reason this happens is because it redraws the char atlas, that's also the reason the time gets greater the more cmd/ctrl + is pressed (more pixels). This could be done using OffscreenCanvas and web workers for browsers that support?

@Tyriar Tyriar changed the title Canvas render window resize is expensive Canvas render window resize that updates devicePixelRatio is expensive Sep 8, 2017
@Tyriar Tyriar mentioned this issue Sep 8, 2017
22 tasks
@Tyriar Tyriar changed the title Canvas render window resize that updates devicePixelRatio is expensive Startup and canvas render window resize that updates devicePixelRatio is expensive Oct 5, 2017
@Tyriar Tyriar added the type/enhancement Features or improvements to existing features label Oct 5, 2017
@Tyriar
Copy link
Member Author

Tyriar commented Oct 5, 2017

The best solution to these two issues is to pull the CharAtlas generation into a web worker. This is blocked on OffscreenCanvas support so that we can draw on a worker thread.

The great thing about this solution is that the terminal can start drawing immediately just fine, the CharAtlas is just an optimization that can come in whenever and it will be picked up and used from that point on,.

@parisk
Copy link
Contributor

parisk commented Oct 6, 2017

Sounds good to me.

Just one question. From what I understand, the CharAtlas needs to be generated every time the zoom factor changes.

If this is true, is the web worker going to be an one-off process or something like a daemon waiting to be requested to generate a new CharAtlas? I think an one-off process would introduce less memory overhead overall.

@Tyriar
Copy link
Member Author

Tyriar commented Oct 6, 2017

One off process is what I'm thinking as it's generally a pretty infrequent thing. If they take a little while to spin up then we could add some time after it's stopped before terminating? (eg. ctrl++ multiple times)

@parisk
Copy link
Contributor

parisk commented Oct 6, 2017

Great catch. 👍

Tyriar added a commit to Tyriar/xterm.js that referenced this issue Jan 6, 2018
This doesn't actually add workers but it separates the code nicely
such that the minimal amount of relevant code can be pulled in by
worker code.

Part of xtermjs#955
@Tyriar
Copy link
Member Author

Tyriar commented Jan 7, 2018

There's an example of generating the char atlas using a web worker at https://github.com/Tyriar/xterm.js/tree/955_worker. I'll probably leave it there for now and wait for Electron to get a version out that supports OffscreenCanvas.

@mofux
Copy link
Contributor

mofux commented Jan 7, 2018

Nice! You can use OffscreenCanvas in electron already by enabling the experimentalCanvasFeatures :

win = new BrowserWindow({
    width: 1200,
    height: 700,
    webPreferences: { experimentalCanvasFeatures: true }
})

https://stackoverflow.com/questions/47271240/can-experimental-features-like-offscreenanvas-be-enabled-in-electron

@Tyriar
Copy link
Member Author

Tyriar commented Jan 7, 2018

Not sure it would be wise to jump in that early though, there would be a lot of these blocked bugs in Chromium v59 https://bugs.chromium.org/p/chromium/issues/detail?id=563816

@mofux
Copy link
Contributor

mofux commented Jan 8, 2018

Seeing that list of open issues I agree it would be wise to wait until it becomes official 😅

@Tyriar
Copy link
Member Author

Tyriar commented Oct 19, 2018

I've seen reports of some of the initial frame draws to the terminal taking 3+ seconds, one way to help this could be to move the atlas stuff out to a worker. That way instead of a new uncached draw doing a draw to both the canvas and the atlas, it would just do the canvas and then request to atlas worker to cache the new char.

@Tyriar Tyriar mentioned this issue Nov 20, 2018
@Tyriar
Copy link
Member Author

Tyriar commented Jun 23, 2019

No plans to implement this for canvas renderer as we'll move towards the webgl addon that was just moved eventually

@Tyriar Tyriar closed this as completed Jun 23, 2019
@Tyriar Tyriar added this to the 4.0.0 milestone Jun 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/performance type/enhancement Features or improvements to existing features
Projects
None yet
Development

No branches or pull requests

3 participants