Render loop redraws on every animation frame, even when nothing changed or the terminal is hidden
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- performance
Research direction
Start with Terminal.startRenderLoop() and compare its behavior with the xterm.js render service mentioned in the issue. Check how writes, resizing, scrolling, selection, hover, focus, cursor blinking, and element visibility should trigger rendering. Done means unchanged or hidden terminals do not redraw every frame, and a terminal renders again when it becomes visible.
Written by the indexing model from the issue text.
Description
Version: ghostty-web 0.4.0 (npm latest)
What happens
Terminal.startRenderLoop() schedules requestAnimationFrame on every frame for as long as the terminal is open, and calls renderer.render() each time. It does this when nothing has changed, and also when the terminal's element is hidden (display: none) or off screen. A page that keeps a terminal mounted in the background, as the Pterodactyl panel 2.0 does so that the console survives tab switches, keeps paying for it on every other page.
Measured in Chromium with 4x CPU throttling on a page that keeps a hidden 170x57 terminal mounted while it receives about 10 lines of output per second: about 1.1 s of long animation frames per 6 s attributed to ghostty-web's frame callback, and roughly 25% fewer frames than the same page without the terminal. Unmounting the terminal removed both.
Suggestion
- Render only when something changed: a write, a resize, scrolling, selection, hover, focus, or the cursor blink. The blink can run on its own timer at its blink rate, not at 60 Hz.
- Pause rendering while the terminal's element is not visible, for example with an
IntersectionObserveron the element, and render once when it becomes visible again. xterm.js does this in its render service.
Related: #198 (at a fractional devicePixelRatio the same loop also resizes and repaints the whole terminal on every frame).
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 193
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from coder/ghostty-web
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
coder/ghostty-web#207 ·
-
buffer translateToString()/getChars() return '' for empty cells, collapsing cursor-positioned textOpen
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
coder/ghostty-web#205 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
coder/ghostty-web#204 ·
-
Alt+<printable key> sends the bare key with no ESC prefix (readline/emacs/tmux meta bindings lost)Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
coder/ghostty-web#203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
coder/ghostty-web#199 ·
All issues in coder/ghostty-web
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
scaleway/ultraviolet#7089 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
tencent-connect/dsh-qqbot#81 ·
Maintainers usually reply within 1 day
-
[Bug]: Pen taps on sidebar rows start a drag and lose their clickPossibly taken @makhnatkin claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
clangd/vscode-clangd#1009 ·