Registering a family changes the thread, and cannot be undone
A family registered by one render is registered for every render after it,
on that thread, for as long as the thread runs. Nothing unregisters anything,
passing different files under the same name replaces what that name draws
from then on, and a render that names a family it never registered will use
whatever an earlier one left behind rather than failing.
That last part is the one to leave with, because it is not an error a log
will show: it is the wrong typeface in a picture nobody looks at twice. A
server that registers per request, one tenant's face at a time, is a server
where the next request quietly renders in the previous tenant's font.
// Register once, where the process starts. constFONTS = [{ family:'Brand', paths: ['./fonts/Brand-Regular.ttf'] }] constcanvas = awaitRoot({ width:200, height:100, fonts:FONTS, children: [] }) canvas.release()
Naming the same list on every render is the pattern to follow. A file whose
bytes this thread already holds under that family adds no face, so memory
does not grow with the number of renders and the GPU draws every render with
the same face. It is varying the list that
is the hazard. Faces belong at start-up, named once, and every render after
that names the same ones.
Each worker thread is its own process for this purpose: they do not share a
registry, so each has to register its own faces, and each is contaminated
only by itself. Two renders already in flight keep their own faces.
The registry lives in meo-skia-canvas, below the addon, and neither surface
can scope it — see crates/meo-canvas-core/src/resolve.rs, which says the
same thing to a Rust caller and has the measurement behind it.
A font family, and the files that make it up.
Registering a family changes the thread, and cannot be undone
A family registered by one render is registered for every render after it, on that thread, for as long as the thread runs. Nothing unregisters anything, passing different files under the same name replaces what that name draws from then on, and a render that names a family it never registered will use whatever an earlier one left behind rather than failing.
That last part is the one to leave with, because it is not an error a log will show: it is the wrong typeface in a picture nobody looks at twice. A server that registers per request, one tenant's face at a time, is a server where the next request quietly renders in the previous tenant's font.
Naming the same list on every render is the pattern to follow. A file whose bytes this thread already holds under that family adds no face, so memory does not grow with the number of renders and the GPU draws every render with the same face. It is varying the list that is the hazard. Faces belong at start-up, named once, and every render after that names the same ones.
Each worker thread is its own process for this purpose: they do not share a registry, so each has to register its own faces, and each is contaminated only by itself. Two renders already in flight keep their own faces.
The registry lives in
meo-skia-canvas, below the addon, and neither surface can scope it — seecrates/meo-canvas-core/src/resolve.rs, which says the same thing to a Rust caller and has the measurement behind it.