Skip to content

fix(gpui): register bundled fonts on macOS - #93

Merged
thebrandonlucas merged 2 commits into
fix/gpui-thread-scroll-crashfrom
fix/gpui-macos-bundled-fonts
Oct 29, 2026
Merged

thebrandonlucas merged 2 commits into
fix/gpui-thread-scroll-crashfrom
fix/gpui-macos-bundled-fonts

Conversation

@thebrandonlucas

@thebrandonlucas thebrandonlucas commented Oct 29, 2026 •

Copy link
Copy Markdown

Layer 4 of the macOS stack, on top of #91.

PR Change
#88 Build the app flake on macOS
#90 Read the identity that buzz-app now stores
#91 Load older thread replies after the list releases its state
this Register bundled fonts on macOS

Problem

On macOS, startup logged buzz-ui: failed to register bundled fonts: Could not load an embedded font. and the app held a CPU core while scrolling and typing.

Core Graphics cannot load the bitmap-only (CBDT) BuzzColorEmoji.ttf. GPUI's macOS add_fonts loads the whole batch with collect::<Result<_>>(), so that one failure dropped Inter and JetBrains Mono as well. Every text style then missed its font. GPUI caches the failed lookup, but it builds a new error on each call and walks its fallback stack (Lilex, IBM Plex Sans, then Helvetica) on every layout. With RUST_BACKTRACE=1, each of those errors also captured a backtrace, which took about 23% of main-thread samples.

Change

crates/ui/src/fonts.rs:

  • Register each bundled font with its own add_fonts call, so one failure can't drop the rest.
  • On macOS, leave BuzzColorEmoji.ttf out of the GPUI fonts. Text styles fall back to Apple Color Emoji there.
  • Linux and Windows still bundle and fall back to Buzz Color Emoji. The emoji-avatar rasterizer still reads EMOJI_FONT through fontdb on every platform.

Validation

  • Swift and Core Graphics load all 9 Inter and JetBrains Mono files; only BuzzColorEmoji.ttf fails.
  • Nix build of buzz-gpui-voltage on aarch64-darwin: the registration error is gone. Idle CPU is about 0.4%. A 4 s sample of the main thread has no font_id, resolve_font or backtrace frames (before: 614 of 2,680).
  • cargo fmt --all --check passes.
  • cargo clippy -p buzz-ui --all-targets --locked -- -D warnings passes in the Nix dev shell.
  • Not checked: colour emoji rendering on macOS with Apple Color Emoji, beyond the app running normally.

Summary by CodeRabbit

  • Bug Fixes
    • Emoji fallback now uses Apple Color Emoji on macOS, where the bundled emoji font cannot be loaded. Other platforms continue to use Buzz Color Emoji. This provides a platform-appropriate fallback for emoji display.

Core Graphics cannot load the bitmap-only (CBDT) Buzz Color Emoji font,
and GPUI rejects a whole add_fonts batch when one font fails. On macOS
that dropped Inter and JetBrains Mono too: every text style missed its
font and fell through GPUI's fallback stack on each layout, which kept
the main thread busy and made scrolling and typing choppy.

Register each font on its own so one failure cannot drop the rest, and
on macOS skip the bundled emoji font and fall back to Apple Color Emoji.
Linux and Windows keep the bundled emoji font.
@thebrandonlucas
thebrandonlucas added this pull request to stack #92 October 29, 2026 13:42
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 27ce92b and e841249.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 4c9bc32 and 27ce92b.

Files selected for processing: 1
  • apps/buzz-gpui/crates/ui/src/fonts.rs

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

Walkthrough

The font configuration now selects an emoji fallback by platform. macOS excludes the bundled bitmap-only emoji font. Font registration now reports failures for each bundled font separately.

Changes: Emoji font handling

Layer / File(s) Summary
Platform-specific font configuration
apps/buzz-gpui/crates/ui/src/fonts.rs
The font list excludes EMOJI_FONT on macOS. FALLBACK_EMOJI selects Apple Color Emoji on macOS and Buzz Color Emoji elsewhere. register() registers fonts separately and logs failures per font. fallbacks() uses the platform-specific fallback name.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested labels: human review wanted

Suggested reviewers: tee8z

Merge Risk: Minimal · previous review 27ce9

No concrete current-head defect was established; the change is ready to merge.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: registering bundled fonts on macOS.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

tee8z
tee8z previously approved these changes Oct 29, 2026

@tee8z tee8z left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving.

  • Registering one font per add_fonts call is the right fix for GPUI's macOS all-or-nothing collect::<Result<_>>(). It also stops one bad font from taking out the rest on Linux and Windows.
  • #[cfg(not(target_os = "macos"))] on the EMOJI_FONT array element is valid. macOS and Windows clippy (-D warnings) pass, so EMOJI doesn't go dead on macOS.
  • The only other user of the bundled emoji, the avatar rasterizer (settings/avatar/raster.rs), loads EMOJI_FONT into its own fontdb and looks up fonts::EMOJI there. It doesn't go through GPUI, so macOS avatar emoji are unaffected.

Optional (doc): in the module comment, "macOS cannot load it, so there the fallback is the system's Apple Color Emoji. Two edits make that work…" now reads as if the two fontTools edits are what make Apple Color Emoji work. Moving the macOS sentence after the bullet list would fix that. That line is also longer than the surrounding wrap width.

Not verified: colour emoji on macOS through Apple Color Emoji (the PR notes this too).

Minimalism 9 · elegance 9 · correctness 9.

@tee8z tee8z left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approving. The earlier approval was dismissed by the stale-review automation when the stack's merge commits propagated #90's fix (17:39:52Z); this PR's own diff is unchanged from what I reviewed. Findings and gates from the previous review stand.

@thebrandonlucas
thebrandonlucas merged commit 6706fa6 into main Oct 29, 2026
40 checks passed
@thebrandonlucas
thebrandonlucas deleted the fix/gpui-macos-bundled-fonts branch October 29, 2026 18:57
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.

2 participants