Skip to content

fix(native): bump godemirror to v0.7.1 for shared fonts and CJK fallback - #819

Merged
omartelo merged 1 commit into
mainfrom
fix/native-godemirror-fonts
Oct 17, 2026
Merged

omartelo merged 1 commit into
mainfrom
fix/native-godemirror-fonts

Conversation

@omartelo

Copy link
Copy Markdown
Collaborator

Why

A heap profile of a real window (LICH_NATIVE_PPROF, from #798) showed the heap growing 117 MB in its first five minutes, 70 MB of it in os.ReadFile under godemirror's internal/glyphs.New, reached from fileCard.ensureView in a pull request's Files tab.

godemirror carried the same two problems #795 and #798 fixed in native/glyphs:

  • Every DiffView, one per file card in the Review and in Pulls, built its own rasterizer that read the font files again.
  • A character the family lacks asked fontconfig for a fallback once per distinct character, fc-list and fc-match -s as subprocesses inside the frame, so a diff full of CJK text stalled.

What changes

native/go.mod moves to godemirror v0.7.1. It reads font files once per process and shares them between views; only the sized face stays per view. It also tries the fallbacks already loaded before looking up again, and reads the monospace ranking once. 50 DiffViews hold about 1 MB of heap where they held 61 MB, with the monospace family alone; a CJK fallback multiplied that per file.

Tests

The tests live in godemirror: TestALoadedFallbackServesTheCharactersItCovers (seen failing before the fix: 20 lookups for 20 characters), TestRasterizersShareAFontFile, TestFallbackLookupsRankAgainstMonospaceOnce; its suite is green with -race. Here, the native/ gate is green with the new version.

godemirror's DiffView, one per file card in the Review and in a pull
request's Files, built a glyph rasterizer of its own that read the font
files again, and asked fontconfig for a fallback once per distinct
character the family lacks, two subprocesses inside the frame. v0.7.1
reads font files once per process and tries the fallbacks already loaded
first: 50 DiffViews hold about 1 MB of heap where they held 61 MB.

Found in a heap profile of a real window (LICH_NATIVE_PPROF): opening one
pull request's Files added 70 MB in os.ReadFile under godemirror's
glyphs.New.
@omartelo
omartelo merged commit bc0d4dd into main Oct 17, 2026
9 checks passed
@omartelo
omartelo deleted the fix/native-godemirror-fonts branch October 17, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant