Skip to content

fix(android): keep a strong reference to the fallback font picker - #405

Open
mfazekas wants to merge 2 commits into
mainfrom
claude/fix-369-font-picker-gc
Open

mfazekas wants to merge 2 commits into
mainfrom
claude/fix-369-font-picker-gc

Conversation

@mfazekas

@mfazekas mfazekas commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

rive-android keeps FontFallbackStrategy.stylePicker only in a WeakReference (still the case in 11.12.1), and HybridRiveFontConfig.applyFallbackFonts() passed it an anonymous object nothing else held. A GC shortly after setFallbackFonts() collected the picker, so text needing a fallback (Thai, Hebrew, Arabic, CJK) rendered blank with FindFontFallback - no fallback found. This keeps a strong reference until clearFallbackFonts(). Affects both Android runtimes, since the file is shared.

Root cause and fix by @edgartoomikw in #369, thanks!

Adds an Issue369FontPickerGC reproducer page: it sets Kanit as the fallback, loads the font another 250 times to make the Java heap collect, then mounts a view showing Thai text. On the Pixel 6 emulator with rive-android 11.12.1, the text is blank without the fix and renders in Kanit with it.

Fixes #369

rive-android stores FontFallbackStrategy.stylePicker in a WeakReference,
so the anonymous picker was collected at the next GC and fallback fonts
silently stopped working (#369).
@mfazekas
mfazekas force-pushed the claude/fix-369-font-picker-gc branch from a85de42 to 4eb9204 Compare October 13, 2026 14:30
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.

[Android] RiveFonts: loadFont({name}) fails for script fonts on OEM fonts.xml; systemFallback() is not script-aware (tofu for Thai/Hebrew/Arabic/CJK)

1 participant