SRB2 for Web, built on Emscripten
This page concerns SRB2 for Web, which enables the game to be played on web browsers. Powered by Emscripten.
Credits
- mazmazz: Adaptation to iOS and Web
- heyjoeway: Initial port to Emscripten
- Jimita: Adaptation of the original game to mobile devices, including touch controls and dynamic resolution.
Issues
Here are the primary issues that I consider blockers before the web app may be ready for primetime.
Memory Usage
The biggest issue is that iOS/Android are crash-prone because of memory limits. Frankly, we don't need the entire game's assets loaded into memory at once, including both the game's memory AND Emscripten's file system.
Two potential solutions:
- The game allocates memory for every texture in the game on startup, jumping the memory usage from 3 MB to 90 MB. Can we make this on-demand per level?
- It would be nice to devise a streaming scheme. Maybe flat-file WAD folders? Have the game load a WAD directory which points to the lumps themselves stored as files in a subfolder.
Wipes and Title Cards
EDIT: Fixed as of 5/30
Wipes are disabled because they block the main thread. Emscripten cannot paint the screen during the wipe, and the music stutters.
I attempted to work around this by treating the wipe loop as a main loop, and manipulating Emscripten's currently set main loop. So far, I have been unsuccessful. See here for the test.
Title cards draw over the wipe for half the duration, then during the level for the other half. Right now, the graphics are not drawn at all because they rely on counters incremented during the wipe.
If title cards can be drawn in the level, then I'm willing to settle for the lack of wipes.
Touch Controls
While usable in their current state, I would like to experiment with tweaked schemes.
Other Issues
-
iOS audio sometimes shuts down after suspending the app and returning to it. AudioContext may be closed by Safari. This should be a reasonable fix; just haven't honed down which variables to check.Appears to be fixed. -
Exit properly. Be able to restart the game runtime within the web page. Need to useDone, but sigsegv (non-I_Quit() exits) not tested.emscripten_exit()
. - Better landing page? Frontend dev is not my strong suit.