Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(text): retire missing-glyph warnings with cached entries

yhhb895207a5c70
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 62bed2730..0f365d201 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,8 @@ published separately; it ships inside the editor.
### Fixed
+- **Missing-glyph warning history follows the bounded cache.** Diagnostic suppression retires when a family no longer has non-drawable glyphs in the 4096-entry CPU cache, preventing historical font names from accumulating. Cached-character queries keep their existing fast path, partial retirement and nested rasterization preserve reference counts, and cleanup releases the history. Unsupported-character warnings no longer claim the entire font cannot draw.
+
- **Automation projection settings persist across editor state changes.** Programmatic perspective changes update the same state used by the editor toggle, so choosing a tool or changing display preferences no longer restores the previous projection. Repeating an unchanged setting avoids UI notifications while reapplying it to the engine; scene cameras remain unedited.
## [0.86.0] - 2026-10-15
diff --git a/sdk/src/ui/text/glyph-atlas.ts b/sdk/src/ui/text/glyph-atlas.ts
index 405110b6e..03ca8d38b 100644
--- a/sdk/src/ui/text/glyph-atlas.ts
+++ b/sdk/src/ui/text/glyph-atlas.ts
@@ -88,6 +88,13 @@ export interface GlyphAtlasOptions {
const STYLE_COUNT_HINT = 4; // plain / bold / italic / bold-italic — for key spread only
+/** Numeric glyph/style/size suffixes leave the complete family prefix intact. */
+function familyFromKey(key: string): string {
+ let end = key.length;
+ for (let i = 0; i < 3; i++) end = key.lastIndexOf('|', end - 1);
+ return key.slice(0, end);
+}
+
/** What a page's cell holds: enough to rasterize the glyph again into the same place. */
interface GlyphPlacement {
codepoint: number;
@@ -112,6 +119,7 @@ export class GlyphAtlas {
private generation_ = 0;
private readonly cache = new Map<string, GlyphEntry>();
private readonly cpuCache = new Map<string, GlyphEntry | null>();
+ private readonly missingCounts_ = new Map<string, number>();
private readonly pages: number[] = [];
private readonly packers: Packer[] = [];
private readonly placements: GlyphPlacement[][] = [];
@@ -141,6 +149,7 @@ export class GlyphAtlas {
this.placements.length = 0;
this.cache.clear();
this.cpuCache.clear();
+ this.missingCounts_.clear();
this.mute_.clear();
this.generation_++;
const errors: unknown[] = [];
@@ -222,7 +231,7 @@ export class GlyphAtlas {
: Math.max(1, Math.round(displaySize * this.dpr * this.contentScale_));
}
- /** Families already reported as producing no glyph — one line each, not one per character. */
+ /** Reported families with non-drawable glyphs still in the bounded CPU cache. */
private readonly mute_ = new Set<string>();
private key(codepoint: number, fontFamily: string, style: number, pixelSize: number): string {
@@ -247,15 +256,13 @@ export class GlyphAtlas {
const raster = this.rasterizer.rasterize(codepoint, fontFamily, style, pixelSize);
if (!raster) {
- // Once per family, because the alternative is what this cost to find:
- // a rasterizer answering null for every codepoint draws no text and
- // says nothing, on a screen full of everything else that worked.
+ // Cached non-drawable glyphs own their family's diagnostic suppression.
+ this.cacheCPU(k, null);
if (!this.mute_.has(fontFamily)) {
this.mute_.add(fontFamily);
log.warn('text', `no glyph for U+${codepoint.toString(16).toUpperCase()} in `
- + `"${fontFamily}" — this family produced none, so its text draws nothing`);
+ + `"${fontFamily}" — this character has no drawable glyph`);
}
- this.cacheCPU(k, null);
return null;
}
@@ -318,9 +325,27 @@ export class GlyphAtlas {
/** Page-free entries can be recreated without changing any live layout or UV. */
private cacheCPU(key: string, glyph: GlyphEntry | null): void {
+ const wasMissing = this.cpuCache.get(key) === null;
this.cpuCache.set(key, glyph);
+ if (glyph === null && !wasMissing) {
+ const family = familyFromKey(key);
+ this.missingCounts_.set(family, (this.missingCounts_.get(family) ?? 0) + 1);
+ } else if (glyph !== null && wasMissing) this.releaseMissing(key);
if (this.cpuCache.size > 4096) {
- this.cpuCache.delete(this.cpuCache.keys().next().value!);
+ const retired = this.cpuCache.keys().next().value!;
+ const wasMissing = this.cpuCache.get(retired) === null;
+ this.cpuCache.delete(retired);
+ if (wasMissing) this.releaseMissing(retired);
+ }
+ }
+
+ private releaseMissing(key: string): void {
+ const family = familyFromKey(key);
+ const count = this.missingCounts_.get(family)! - 1;
+ if (count > 0) this.missingCounts_.set(family, count);
+ else {
+ this.missingCounts_.delete(family);
+ this.mute_.delete(family);
}
}
diff --git a/sdk/tests/ui-glyph-atlas.test.ts b/sdk/tests/ui-glyph-atlas.test.ts
index 2f5d41ab7..443140ed6 100644
--- a/sdk/tests/ui-glyph-atlas.test.ts
+++ b/sdk/tests/ui-glyph-atlas.test.ts
@@ -15,6 +15,7 @@ import {
} from '../src/ui/text/glyph-atlas';
import { layoutText } from '../src/ui/text/layout';
+import { log } from '../src/util/logger';
const UNKNOWN = 0xffff;
const SPACE = 32;
@@ -45,6 +46,115 @@ function makeStore() {
}
describe('REARCH_GUI P1.1c: GlyphAtlas', () => {
+ it('does not double-count a cache slot populated during rasterization', () => {
+ const warning = vi.spyOn(log, 'warn').mockImplementation(() => {});
+ let nested = false;
+ const atlas: GlyphAtlas = new GlyphAtlas({
+ renderSize: 48, spread: 0,
+ rasterize: (cp, family) => {
+ if (!nested) {
+ nested = true;
+ atlas.getGlyph(cp, family);
+ nested = false;
+ }
+ return null;
+ },
+ }, null);
+ const state = atlas as unknown as { mute_: Set<string>; missingCounts_: Map<string, number> };
+ try {
+ for (let i = 0; i < 4097; i++) atlas.getGlyph(65, `nested-${i}`);
+ expect(state.missingCounts_.size).toBe(4096);
+ expect(state.missingCounts_.get('nested-4096')).toBe(1);
+ expect(state.mute_.has('nested-0')).toBe(false);
+ } finally {
+ warning.mockRestore();
+ }
+ });
+
+ it('keeps diagnostics until the last cached missing character of a family retires', () => {
+ const warning = vi.spyOn(log, 'warn').mockImplementation(() => {});
+ const atlas = new GlyphAtlas({ renderSize: 48, spread: 0, rasterize: () => null }, null);
+ const state = atlas as unknown as { mute_: Set<string>; cpuCache: Map<string, unknown>; missingCounts_: Map<string, number> };
+ try {
+ atlas.getGlyph(65, 'same|family|name');
+ atlas.getGlyph(66, 'same|family|name');
+ for (let i = 0; i < 4095; i++) atlas.getGlyph(65, `other-${i}`);
+ expect(state.mute_.has('same|family|name')).toBe(true);
+ expect(state.missingCounts_.get('same|family|name')).toBe(1);
+ atlas.getGlyph(65, 'last-other');
+ expect(state.mute_.has('same|family|name')).toBe(false);
+ const calls = warning.mock.calls.length;
+ atlas.getGlyph(67, 'same|family|name');
+ expect(warning).toHaveBeenCalledTimes(calls + 1);
+ expect(state.cpuCache.size).toBe(4096);
+ expect(state.missingCounts_.size).toBe(4096);
+ atlas.dispose();
+ expect(state.cpuCache.size).toBe(0);
+ expect(state.missingCounts_.size).toBe(0);
+ } finally {
+ warning.mockRestore();
+ }
+ });
+
+ it('does not reorder diagnostic history for repeated cached characters of one family', () => {
+ const warning = vi.spyOn(log, 'warn').mockImplementation(() => {});
+ const atlas = new GlyphAtlas({ renderSize: 48, spread: 0, rasterize: () => null }, null);
+ const state = atlas as unknown as { mute_: Set<string> };
+ try {
+ atlas.getGlyph(UNKNOWN, 'missing');
+ const reorder = vi.spyOn(state.mute_, 'delete');
+ for (let i = 0; i < 10000; i++) atlas.getGlyph(UNKNOWN, 'missing');
+ expect(reorder).not.toHaveBeenCalled();
+ expect(warning).toHaveBeenCalledTimes(1);
+ } finally {
+ warning.mockRestore();
+ }
+ });
+
+ it('reports an unsupported character without claiming the whole font cannot draw', () => {
+ const warning = vi.spyOn(log, 'warn').mockImplementation(() => {});
+ const atlas = new GlyphAtlas(makeRasterizer(), makeStore());
+ try {
+ expect(atlas.getGlyph(65, 'Arial')).not.toBeNull();
+ expect(atlas.getGlyph(UNKNOWN, 'Arial')).toBeNull();
+ expect(warning).toHaveBeenCalledWith('text', expect.stringContaining('this character has no drawable glyph'));
+ expect(atlas.getGlyph(66, 'Arial')).not.toBeNull();
+ } finally {
+ warning.mockRestore();
+ }
+ });
+
+ it('bounds missing-family diagnostics while keeping a cached hot family muted', () => {
+ const warning = vi.spyOn(log, 'warn').mockImplementation(() => {});
+ const rasterizer: GlyphRasterizer = { renderSize: 48, spread: 6, rasterize: () => null };
+ const atlas = new GlyphAtlas(rasterizer, null);
+ const state = atlas as unknown as { mute_: Set<string>; cpuCache: Map<string, unknown> };
+ try {
+ atlas.getGlyph(UNKNOWN, 'hot-family');
+ for (let i = 0; i < 12000; i++) {
+ atlas.getGlyph(UNKNOWN, `missing-family-${i}`);
+ if (i % 16 === 0) atlas.getGlyph(UNKNOWN, 'hot-family');
+ }
+ expect(state.mute_.size).toBeLessThanOrEqual(4096);
+ expect(state.cpuCache.size).toBeLessThanOrEqual(4096);
+ expect(state.mute_.has('hot-family')).toBe(true);
+ expect(state.mute_.has('missing-family-0')).toBe(false);
+ expect(warning).toHaveBeenCalledTimes(12001);
+ atlas.getGlyph(UNKNOWN + 1, 'hot-family');
+ expect(warning).toHaveBeenCalledTimes(12001);
+ atlas.getGlyph(UNKNOWN, 'missing-family-0');
+ expect(warning).toHaveBeenCalledTimes(12002);
+ expect(atlas.pageCount).toBe(0);
+ expect(atlas.generation).toBe(0);
+ atlas.dispose();
+ expect(state.mute_.size).toBe(0);
+ atlas.getGlyph(UNKNOWN, 'hot-family');
+ expect(warning).toHaveBeenCalledTimes(12003);
+ } finally {
+ warning.mockRestore();
+ }
+ });
+
it('releases every page once, including when one release fails, and clears cached glyphs', () => {
const rasterizer = makeRasterizer();
const store = makeStore();
@@ -279,8 +389,8 @@ describe('page-free glyph cache lifetime', () => {
const calls = rasterizer.rasterize.mock.calls.length;
atlas.getGlyph(cp, 'Arial', 0, 1);
expect(rasterizer.rasterize.mock.calls.length).toBe(calls + 1);
- const entries = Object.values(atlas).filter(v => v instanceof Map)
- .reduce((total, map) => total + map.size, 0);
+ const glyphCaches = atlas as unknown as { cache: Map<string, unknown>; cpuCache: Map<string, unknown> };
+ const entries = glyphCaches.cache.size + glyphCaches.cpuCache.size;
expect(entries).toBeLessThanOrEqual(4097);
expect(atlas.getGlyph(cp, 'Arial', 0, 2)).toBe(hot);
if (drawable) {
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 6aef7e3fb..abcaed944 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -28,6 +28,8 @@ export const NOTES_FLOOR = 'v0.65.0';
* the reader recognises anyway.
*/
export const NOTED = {
+ 'fix(text): retire missing-glyph warnings with cached entries':
+ { note: 'Missing-glyph warning history follows the bounded cache.' },
'test(editor): verify projection resets to 2D after gestures':
{ note: 'Automation projection settings persist across editor state changes.' },
'test(native): retain first launch evidence before retry':