fix: suppress spurious font warnings during R3F teardown#261
Open
sawa-zen wants to merge 1 commit into
Open
Conversation
When React Three Fiber unmounts components, `removeChild` calls `parent.object.remove(child.object)` which triggers uikit's "removed" event handler. This resets properties via `setEnabled(false)`, causing `fontFamiliesSignal.value` to become undefined. The `computedFont` effect then re-evaluates, falls back to the default inter font, and logs "unknown font family" / "Missing glyph info" warnings for any non-Latin characters. These warnings are harmless (the component is being destroyed) but noisy. This fix skips font loading when `fontFamiliesSignal.value` is undefined, which reliably indicates a fallback/teardown state rather than an explicit font configuration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Problem
When React Three Fiber unmounts a component tree,
removeChildcallsparent.object.remove(child.object)on each three.js object. This triggers uikit's"removed"event handler (updateParentState), which callsproperties.setEnabled(false), resetting all property signals to their defaults.Since
computedFontuses a raweffect()(not controlled byabortController), it re-evaluates whenfontFamiliesSignalchanges toundefined. The effect falls back todefaultFontFamiles({ inter }), and if the component had a non-defaultfontFamily(e.g."ja"for Japanese), it logs:unknown font family "ja". Available font families are "inter". Falling back to "inter".Missing glyph info for character "ラ"(for each character not in the inter font)These warnings are harmless — the component is being destroyed — but noisy, especially with CJK text that produces one warning per character.
Fix
Skip font loading when
fontFamiliesSignal.valueisundefined. This value beingundefinedreliably indicates a fallback/teardown state (properties have been reset) rather than an explicit font configuration. In normal operation,fontFamiliesSignal.valueis always set (either from own props or inherited from parent).This prevents both the "unknown font family" error and the subsequent "Missing glyph info" warnings.
Reproduction
ContainerwithfontFamiliesincluding a non-Latin fontTextchildren withfontFamilyset to that font