Repository navigation
fix: a font macOS would download is no match, where asking for one by name put up a download prompt and held the call until it was answered - #141
Merged
Conversation
… name put up a download prompt and held the call until it was answered
macOS lists some 1,300 faces it downloads on demand (Hei, Kai, Songti, …), and `fontWithDescriptor:`, `fontWithName:` or CTFontCreateWithName of one, in a process with an NSApp, puts up "<app> needs to download the font …" and blocks the call. react-x11's browser hands matchFont a page's whole font stack, and Chinese fallback stacks name these families, so a page stopped its process on a prompt per font.
matchFont, fontByPostScriptName, listFonts({ family }) and a pop-up's fontFamily now match only a family or PostScript name of a face available now — CoreText's collection of available fonts, which activates nothing — and pass over any other as they pass over a name nobody has. The names are kept until the registered fonts change. `fontAvailable(name)` answers the same question for a caller.
test/font-download.js (in npm test and CI) takes the first family in the system's downloadable catalog that this machine lacks and matches it ahead of Menlo in an app with a window, in a child killed if the call is held. buildFace moves to test/build-face.js.
sidorares
force-pushed
the
fix/no-font-auto-activation
branch
from
December 1, 2026 05:20
93144cf to
c304df0
Compare
sidorares
added a commit
to sidorares/react-x11-components
that referenced
this pull request
Dec 1, 2026
…cOS would download no longer holds its tab on a Mac (#2398) appkit 0.34.1 is windowkit/appkit#141: a family or PostScript name that macOS lists only for download, such as Hei, Kai, STHeiti or Microsoft YaHei, is no match, where asking for one by name had macOS look for the download and hold the call. Core 3.3.0's range, `^0.34.0`, admits it, so only the lockfile moves. Nothing in `src/` changes and nothing ships, since an app resolves core's appkit itself. Chinese font stacks name those families as a matter of course, and core's Cocoa font manager hands `matchFont` the whole list `<Html>` sets a run in. Measured on a Mac with none of them installed, in the example browser on the Cocoa backend, with a page whose stacks are `Hei, Kai, STHeiti, Microsoft YaHei, PingFang SC, sans-serif` and `Hei`, and an `@font-face` whose sources are `local("Hei")` and `local("Kai")`: | `matchFont` in the tab's process | 0.34.0 | 0.34.1 | | --- | --- | --- | | `Hei, sans-serif`, the first named lookup | 9,619 ms | 38 ms, which builds appkit's list of names | | `Kai`, for `local()` | 2,137 ms | 0 ms | | the whole stack | 1,133 ms | 2 ms | That is some 13 seconds before the page's first paint on 0.34.0, near the 15 seconds after which `<Frame>` ends a pane that stops answering. A probe that asked a pane for `Hei, Menlo` went past it, and the pane was ended. A probe in a process with a window and an NSApp, as the browser's own process is, held for 15 seconds until it was killed, which is where windowkit/appkit#141 saw macOS put up its download dialog. On 0.34.1 every one of them answers at once, and the stack sets the text in PingFang SC. Checked besides: a page of 100 scripts with no family named, which falls back through CoreText's own cascade, a path windowkit/appkit#141 does not touch, lays out with no call over 150 ms, and nothing was downloaded: `fontAvailable` answers false for Hei after every run.
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.
macOS lists some 1,300 faces it downloads on demand — Hei, Kai, Songti and the rest of the CJK sets among them (
/System/Library/AssetsV2/com_apple_MobileAsset_Font8). Asking AppKit or CoreText for one by name (fontWithDescriptor:,fontWithName:,CTFontCreateWithName), in a process with an NSApp, puts up " needs to download the font …" and blocks the call until someone answers it.react-x11's browser example hands
matchFonta page's whole font stack, and Chinese fallback stacks name these families as a matter of course, so a page stopped its process on a prompt per font. Reproduced withmatchFont({ families: ['Hei', 'Menlo'] })afterinitAppand a window: the dialog came up and the call did not return.The change.
BFontAvailable(name)answers whether a name, in any case, is a family or PostScript name of a face available now — installed, or registered by the process — fromCTFontCollectionCreateFromAvailableFonts, which lists no downloadable face and activates nothing. The names are kept untilkCTFontManagerRegisteredFontsChangedNotification(andloadFontDatabumps the generation itself). Names CoreText hides (.SF NS) pass. It is asked first by:matchFont'sResolveFamily— a name that fails is not found, and the list moves on, as for a name nobody has;fontByPostScriptName;listFonts({ family });fontFamily(PopUpFont).fontAvailable(name)exposes the same answer, and the README has a section on it. Nothing is downloaded and nothing is asked.Tests.
test/font-download.js(added tonpm testand a CI step) checksfontAvailableon installed families and PostScript names, then takes the first family in the downloadable catalog this machine lacks and matches it ahead of Menlo in an app with a window, in a child process killed if the call is held; it skips the match where there is no catalog. Here it picked Hopper Script and answered Menlo at once; the same probe with Hei againstmainheld on the dialog.buildFacemoved fromtest/font-from-data.jstotest/build-face.js.npm testpasses up totest/threaded.js, whosefullcase ("the folded move is not the latest", 27.46 against 29) fails identically on unmodifiedmainon this machine; every test after it passes.Two CI jobs failed once each and passed when run again: Node 22 in
test/threaded-resize.js("the content matches the window", 305×203 against 400×260) and Node 26 intest/surface-colorspace.js(a blank capture, "the window was not composited"). Neither touches fonts. The new step passes on 18, 22 and 26.