Skip to content

Fix MV Scene_Boot hang: measureText was font-agnostic, breaking Graphics.isFontLoaded - #1152

Merged
take-cheeze merged 2 commits into
masterfrom
claude/mv-gamefont-measuretext-fix
Aug 20, 2026
Merged

Fix MV Scene_Boot hang: measureText was font-agnostic, breaking Graphics.isFontLoaded#1152
take-cheeze merged 2 commits into
masterfrom
claude/mv-gamefont-measuretext-fix

Conversation

@take-cheeze

Copy link
Copy Markdown
Owner

Summary

  • MV's classic font-ready check (Scene_Boot.isGameFontLoaded, via Graphics.isFontLoaded) measures '40px GameFont, sans-serif' against '40px sans-serif' and waits for the two widths to diverge. Our measureText (mruby-mvjs/src/mvcanvas.cxx) backed every font shorthand with the same loaded game font regardless of the requested family, so those two measurements were always identical and the check never passed — Scene_Boot would hang until its own 20s timeout and throw Error: Failed to load GameFont, on any project whose corescript takes this path rather than the newer FontFaceSet path our document.fonts stand-in already covers.
  • Found against a real, downloaded RPG Maker MV release (an Enigma Virtual Box-packed single-file distributable, unpacked with evbunpack to reach its www/ project) that never got past Scene_Boot.
  • Fixed by having measureText/fillText/strokeText parse whether the font shorthand actually names "GameFont" and route anything else through the same rough per-character estimate already used when no game font is loaded at all — guaranteed to differ from the real metrics.
  • data/Lunatic-Core and data/mv-sample both happen to use a corescript build that takes the FontFaceSet path already, which is why this stayed hidden until a different real release exercised the older one.

Test plan

  • Verified against the real game: it now reaches Scene_Boot → Scene_Title → New Game → Scene_Map (previously stuck at Scene_Boot forever)
  • rake test (mrbtest): 1842 OK, 0 KO, 0 Crash — includes a new regression test in mruby-mvjs/test/canvas_test.rb that asserts the exact fallback value for a non-"GameFont" shorthand, independent of whether a real font happens to be loaded in the test environment
  • Full rebuild + existing MV smoke probes (move/battle/menu/save/audio/message) against Lunatic-Core and mz-sample: all still green, no regressions

🤖 Generated with Claude Code

https://claude.ai/code/session_01RmARb1uB2F9rXRg6tQsGgR


Generated by Claude Code

…ics.isFontLoaded

MV's classic font-ready check (Scene_Boot.isGameFontLoaded, via
Graphics.isFontLoaded) measures '40px GameFont, sans-serif' against
'40px sans-serif' and waits for the two widths to diverge. Our
measureText (mruby-mvjs/src/mvcanvas.cxx) backed every font shorthand
with the same loaded game font regardless of the requested family, so
those two measurements were always identical and the check never
passed -- Scene_Boot would hang until its own 20s timeout and throw
"Error: Failed to load GameFont", on any project whose corescript
takes this path rather than the newer FontFaceSet path our
document.fonts stand-in already covers.

Found against a real, downloaded RPG Maker MV release (an Enigma
Virtual Box-packed single-file distributable, unpacked with evbunpack
to reach its www/ project) that never got past Scene_Boot. Fixed by
having measureText/fillText/strokeText parse whether the font
shorthand actually names "GameFont" and route anything else through
the same rough per-character estimate already used when no game font
is loaded at all -- guaranteed to differ from the real metrics.
Verified: the same real game now reaches Scene_Title, New Game and
Scene_Map. data/Lunatic-Core and data/mv-sample both happen to use a
corescript build that takes the FontFaceSet path already, which is
why this stayed hidden until a different real release exercised the
older one.

Adds a regression test in mruby-mvjs/test/canvas_test.rb (asserts the
exact fallback value for a non-"GameFont" shorthand, independent of
whether a real font happens to be loaded in the test environment) and
documents the root cause in docs/TODO.md's M5 section.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RmARb1uB2F9rXRg6tQsGgR
@github-actions github-actions Bot added component:graphics Rendering: bitmaps, tilemaps, sprites, windows, fonts component:runtime-js QuickJS host for MV/MZ: JS bindings, canvas, WebGL component:docs README, /docs, ADRs, changelog fragments labels Aug 20, 2026
CI's clang-format pre-commit hook reflows the font_text_width signature
and a comment block differently than my by-hand wrapping. Reformatted
to the tool's own output (verified locally: clang-format -i now
produces no diff).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RmARb1uB2F9rXRg6tQsGgR
@take-cheeze
take-cheeze merged commit c42a578 into master Aug 20, 2026
11 checks passed
@take-cheeze
take-cheeze deleted the claude/mv-gamefont-measuretext-fix branch August 20, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:docs README, /docs, ADRs, changelog fragments component:graphics Rendering: bitmaps, tilemaps, sprites, windows, fonts component:runtime-js QuickJS host for MV/MZ: JS bindings, canvas, WebGL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants