Skip to content

WasmPlayer: fix game resource images not loading#1784

Merged
alexwarren merged 2 commits into
mainfrom
fix/wasm-resource-images
Jun 29, 2026
Merged

WasmPlayer: fix game resource images not loading#1784
alexwarren merged 2 commits into
mainfrom
fix/wasm-resource-images

Conversation

@alexwarren

@alexwarren alexwarren commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Game resources (images, audio, etc.) were being registered as data URLs before WorldModel.Initialise() ran — at that point ResourceGetter/GetResourceNames are still null, so nothing was ever registered and images 404'd
  • Fixed by moving resource registration to after _helper.Initialise(), then improved further with lazy loading:
    • Resources are now converted to base64 data URLs on demand the first time GetURL() is called, rather than all upfront at startup
    • Games with tens of MB of resources no longer pay the cost of loading everything they may never use
    • Data URLs (not blob URLs) are used so image src values embed directly into the saved HTML — save/restore works correctly across page loads
    • Data URL construction moved from JS to C#, removing a JS interop round-trip per resource
  • PackageReader made case-insensitive and null-safe for resource lookups

Test plan

  • Load /examples/images.quest in WasmPlayer — images should display correctly
  • Verify other game examples still work (no regression in games without resources)
  • Save and restore a game with images — images should still display after restore

🤖 Generated with Claude Code

alexwarren and others added 2 commits June 29, 2026 05:32
Resource registration was attempted before WorldModel.Initialise(),
at which point ResourceGetter/GetResourceNames are still null, so no
resources were ever registered as data URLs. Moving the loop to after
Initialise() ensures the PackageReader has populated those delegates
from the .quest zip file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Instead of converting all resources to base64 data URLs at startup,
generate them on demand the first time GetURL() is called for each
resource. This avoids loading tens of MB of images/audio that may
never be used, while keeping data URLs (vs. blob URLs) so they embed
correctly in saved HTML and survive save/restore.

Also makes PackageReader case-insensitive and null-safe so resource
lookups are robust regardless of capitalization in the zip.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@alexwarren alexwarren merged commit c5a5506 into main Jun 29, 2026
3 checks passed
@alexwarren alexwarren deleted the fix/wasm-resource-images branch June 29, 2026 04:43
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.

1 participant