chrismaltby / gb-studio

A quick and easy to use drag and drop retro game creator for your favourite handheld video game system
https://www.gbstudio.dev
MIT License
8.57k stars 473 forks source link

Web export html doesn't work offline, only works if uploaded to a website/itch #793

Open long-boy opened 3 years ago

long-boy commented 3 years ago

Describe the bug I'm guessing this is considered a bug, but it could be a missing feature.

The exported web html version only works if connected to the internet through a website or itch.io, but it doesn't work if just opening the html file offline. I just get a blank screen. Online works 100% (I've deployed to itch and my own netlify site). The Grant Galitz's JavaScript GameBoy Color Emulator (https://github.com/taisel/GameBoy-Online) which is the base emulator does work offline, so I feel the fix is possible. Maybe some caching needs to be done? I tried comparing the javascript files of the original emulator and the GB Studio fork to find the difference causing the problem, but couldn't find a solution (my js and html knowledge is pretty basic).

To Reproduce Opening the built index.html from desktop.

Expected behavior It would be nice to have offline compatibility for different options of publishing and delivering the game.

Additional comments I realize it may not be within the scope of GB Studio or really needed by many people, but I would like the functionality so if someone has a workaround I would greatly appreciate it!

lunarcloud commented 3 years ago

It does work from a local server, just not from "file://" (double clicking index.html)

I don't believe it's technically possible to "fix" this in the code. User can either:

  1. play from editor...
  2. load this in a web server (on their machines or online).
  3. launch their browser with arcane arguments to disable CORS issues with local files.
pblca commented 2 years ago

Recommend for closing @chrismaltby

scottamass commented 1 year ago

I have a suggestion try wrapping in a paw it should give you offline support

lunarcloud commented 1 year ago

try wrapping in a paw

PAW? Do you mean PWA? The existence of a PWA manifest won't fix the 'local files' issue.

I think the user wants to distribute the game offline and without requiring an emulator. You could bundle the web page into a wrapper like https://nwjs.io/ - though there's probably a might lighter-weight way of bundling the games with a desktop-native emulator for distribution on places like steam/itch/etc