fix(web): load terminal webfont before first paint and invalidate WebGL atlas - #1770
Merged
Merged
Conversation
…GL atlas @font-face files fetch lazily on first use and xterm never observes font loading, so a terminal mounted on a cold font cache rasterized fallback glyphs. The WebGL renderer baked them into its texture atlas for the whole session. Await the resolved font family (bounded) before term.open and rebuild the atlas on every font loadingdone event while WebGL is live.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Terminal mounts raced the JetBrains Mono webfont download.
@font-facefiles fetch lazily on first use and xterm never observes font loading, so a terminal opened on a cold font cache rasterized fallback glyphs. On the WebGL renderer (browser clients) those glyphs were baked into the texture atlas and stayed wrong for the whole session; some users saw Courier New instead of JetBrains Mono.init()now warmsdocument.fonts.load()for the resolved font family in parallel with the xterm module imports and awaits it, capped at 500 ms, beforeterm.open. A newwatchWebfontSettlehelper listens forloadingdonewhile the WebGL addon is live and callsclearTextureAtlas()plus a full refresh, which also covers lazily fetched unicode-range subsets. The listener is removed through the existingclaimWebglSlotrelease path, so teardown and context-loss swaps stay clean. Font load failure or timeout never blocks the mount; the CSS fallback chain still applies.Why
The bundled JetBrains Mono is the intended terminal default but never reliably reached the screen. Users on a cold cache, slower connections, or the WebGL renderer got a stuck fallback face while Electron (DOM renderer) self-healed, which made the bug look per-user.
UI Changes
Correct rendering is the existing JetBrains Mono terminal font; there is no visual change when the font was already loading in time. The reported failure mode is a terminal stuck in the browser monospace fallback (Courier New on Windows/Firefox). Before/after capture via the live-testing harness was not feasible: Playwright is not installed in this environment (install requires approval), and the Electron path does not exercise the affected WebGL renderer. Verified instead by typecheck, lint, the terminal test suite, and confirming the dev server serves the fontsource CSS and woff2 assets (HTTP 200).
Review Notes
TerminalView.search.test.tsx"addon failure recovery") fails identically on the unmodified file and is pre-existing.document.fontsaccess is guarded for non-browser test environments.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.