fix(mv): stop PIXI's BaseTexture from clobbering Bitmap's onload handler - #1058
Merged
Conversation
The player never actually moved in any MV game: Scene_Map never became
active because the tileset Bitmap got permanently stuck at
_loadingState: 'requesting'. Root cause was the Image shim aliasing
addEventListener('load'/'error', ...) to the single onload/onerror
property slot. Bitmap#_requestImage attaches its own completion
handler that way, but PIXI's BaseTexture also assigns image.onload
directly when wrapping an incomplete Image -- on a real browser these
are independent listener slots that both fire, but our shim let
PIXI's later direct assignment silently discard MV's own handler.
Image now keeps addEventListener-registered listeners and the
onload/onerror properties independent, firing both. Also added a
generation counter so a stale queued completion from a previous .src
assignment can't land on a reused Image instance (MV pools and reuses
Image objects via Bitmap._reuseImages) after a new owner has already
re-armed it.
Verified against both data/mv-sample and the downloaded Lunatic-Core
bed: [MV-MOVE] now reports moved=true consistently. Added the missing
CI assertion (grep for moved=true, matching the MZ movement smoke)
to the two MV movement-relevant smoke steps so a regression here
fails CI directly instead of only being visible by reading logs.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RmARb1uB2F9rXRg6tQsGgR
take-cheeze
enabled auto-merge
August 19, 2026 02:14
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.
Summary
[MV-MOVE] ... moved=falseon every probe, on bothdata/mv-sampleand the downloadeddata/Lunatic-Corebed) becauseScene_Mapnever became active: the map tileset'sBitmapgot permanently stuck at_loadingState: 'requesting'.Object.definePropertywatchpoint on the tilesetImage'sonload(capturing a JS stack on every write): ourImageshim (mruby-mvjs/src/mvcanvas.cxx) aliasedaddEventListener('load'/'error', cb)to the singleonload/onerrorproperty.Bitmap#_requestImageattaches its own completion handler that way, but PIXI'sBaseTexturealso assignsimage.onloaddirectly when wrapping an incompleteImage(to learn when it finishes loading) — on a real browser these are independent listener slots that both fire, but our shim let PIXI's later direct assignment silently discard MV's own handler.Imagenow keepsaddEventListener-registered listeners and theonload/onerrorproperties independent, firing both — matching the real DOM contract..srcassignment can't land on a reusedImageinstance after a new owner has already re-armed it (MV pools and reusesImageobjects viaBitmap._reuseImages).moved=truegrep. Both MV movement-relevant smoke steps now assert it too.Test plan
./build/mruby/host/bin/mrbtest— 1818/1818 OK, 0 failuresbash scripts/mz_boot_check.bash— all MZ smokes pass (sharedImageshim, unaffected)data/mv-sample:[MV-MOVE] ... moved=trueconsistently across repeated runsdata/Lunatic-Core(real downloaded game):[MV-MOVE] ... moved=truedocs/TODO.mdM5 write-up updated to reflect the fix (was⚠️, now✅); M5 milestone header flipped to✅Generated by Claude Code