|
| 1 | +--- |
| 2 | +title: Synchronized Output |
| 3 | +description: |- |
| 4 | + Command-line programs that update large swaths of the visible screen might |
| 5 | + show screen tearing on fast terminals like Ghostty, when synchronized |
| 6 | + output is not enabled. |
| 7 | +--- |
| 8 | + |
| 9 | +On some systems, command-line programs that frequently update large swaths of |
| 10 | +the visible screen might repeatedly flicker or exhibit severe screen tearing |
| 11 | +when using Ghostty, which does not occur with other terminal emulators. |
| 12 | +**This is usually not a bug with Ghostty, but rather a bug with the programs |
| 13 | +themselves.** |
| 14 | + |
| 15 | +Often the reason behind this is that Ghostty is rendering **too quickly**, |
| 16 | +and the programs that are redrawing the screen are not updating the cells |
| 17 | +on the screen fast enough to catch up with the renderer — hence, tearing. |
| 18 | + |
| 19 | +There's not much Ghostty can do here without compromising performance, and |
| 20 | +therefore we **highly encourage** users of affected programs to file issues |
| 21 | +to upstream developers with a link to the ["For developers"](#for-developers) |
| 22 | +section of this page, so that they know how to fix the underlying problem. |
| 23 | + |
| 24 | +Programs known to be affected by this include: |
| 25 | + |
| 26 | +- Claude Code ([#8176], [#8285]) |
| 27 | +- Docker CLI ([#5493], [#5657], [#8162]) |
| 28 | +- Ollama ([#4048]) |
| 29 | +- Grok ([#9618]) |
| 30 | + |
| 31 | +[#4048]: https://github.com/ghostty-org/ghostty/discussions/4048 |
| 32 | +[#5493]: https://github.com/ghostty-org/ghostty/discussions/5493 |
| 33 | +[#5657]: https://github.com/ghostty-org/ghostty/discussions/5657 |
| 34 | +[#8162]: https://github.com/ghostty-org/ghostty/discussions/8162 |
| 35 | +[#8176]: https://github.com/ghostty-org/ghostty/discussions/8176 |
| 36 | +[#8285]: https://github.com/ghostty-org/ghostty/discussions/8285 |
| 37 | +[#9618]: https://github.com/ghostty-org/ghostty/discussions/9618 |
| 38 | + |
| 39 | +## For developers |
| 40 | + |
| 41 | +If you're a developer of a CLI or TUI-based app that has this issue, you |
| 42 | +need to implement the [Synchronized Output] protocol which signals Ghostty |
| 43 | +(and other modern, performant terminal emulators) when the screen has been |
| 44 | +fully updated, and it is safe to render the next frame. |
| 45 | + |
| 46 | +However, as a best practice we also recommend **only updating the cells that |
| 47 | +absolutely need to be updated**, and avoid erasing whole rows or the entirety |
| 48 | +of the active screen before updating new cells. Instead, you can reset the |
| 49 | +cursor to the part to be updated by using [Cursor Position (CUP)], update the |
| 50 | +cells, and erase the rest of the line using [Erase in Line (EL)]. This not |
| 51 | +only ameliorates the screen tearing on terminals that may not support the |
| 52 | +Synchronized Output protocol, but can also greatly increase performance by |
| 53 | +reducing needless updates and the amount of data sent to the terminal. |
| 54 | + |
| 55 | +[Synchronized Output]: https://github.com/contour-terminal/vt-extensions/blob/1a9fde53d80c4a60b1be44c5a4492d86ec9f9cce/synchronized-output.md |
| 56 | +[Cursor Position (CUP)]: /docs/vt/csi/cup |
| 57 | +[Erase in Line (EL)]: /docs/vt/csi/el |
0 commit comments