Skip to content

Unsolved Issues

Mike Roibu edited this page Mar 9, 2024 · 3 revisions

There are a number of issues that have no workarounds, or all the workarounds are difficult/non-ideal.

SDL/GL Emscripten Issues

There are a number of things that don't work the same way in a web context, and SDL/Emscripten/etc haven't been able to work around them. Instead they generally require knowledge of the platform you're running on, and specialised code to work around.

A number of these are listed here on the SDL Emscripten documentation page.

These include things like: the audio devices function differently and will only actually play audio/capture input after permissions are given or after a user interacts with a page, SDL_RenderPresent won't do anything because of how rendering works.

There are a few more not mentioned, around things that do not get handled in OpenGL calls but instead are expected to be set on the WebGL context (via Javascript/HTML). These are generally fairly specialised calls and it should be obvious if that's the issue (or searching for the error message will find an explanation). Using [JsImport] and [JsExport] it's possible to have C# calls that call the relevant behaviour.

Importantly, threading is also starting to be supported but has a number of restrictions/limitations and is difficult to use. Not currently recommended, and would require a rebuilt SDL anyway.

Song and SoundEffect Limitations

Specifically for FNA, there is a limitation on using both Song and SoundEffect within the same application, when using SDL2. This limitations stems from this SDL2 issue. Technically it could be worked around within FNA/FAudio by changing the behaviour, but that would break compatibility with XNA which is not ideal; the better approach would be for SDL to handle the platform the way it gets handled on other platforms.

Effectively, when SoundEffect is loaded and when a Song is played, both things will trigger the same calls to FAudio/SDL to create an audio device/mastering voice. Because Song does it internally within FAudio, and SoundEffect does it explicitly in FNA, but neither exposes the actual pointers to the relevant data, there's no easy workaround to start one and then jump-start the other onto the same device/mastering voice (and that may not work anyway without FNA-side code to combine the two output streams).

On SDL on non-Web platforms (and on old XNA presumably) this would just hit the OS which would open two audio devices (even if the OS only really had one) and get two sets of callbacks to play, leading the system to basically mix the incoming audio streams together onto the same playback device.

On SDL on Web this ends up breaking because they won't allow the single audio device to be opened twice, because Emscripten explicitly only supports a single default audio output device, so they explicitly check for it. The functionality for 'mixing' on non-Web platforms is not really intentional and is just something offered by the OS, so Emscripten not supporting it means it's the "right" thing to do in this case.

As per the issue, this functionality has been extended/improved in SDL3 and presumably is possible to work around easily there, but SDL3 is not used at time of writing.

Clone this wiki locally