The future of Emscripten and OF?

I wonder if there will be an update in the future, so that OF will work with the current Emscripten version. Right now the official Emscripten version to use is 1.40.0 and with a small change it also works with 2.0.6. What does not work with both versions is fullscreen and antialiasing of 2d-shapes. I also needed to change some code for using ofTrueTypeFont with Emscripten. And it would be very nice to use audioWorkletNode instead of ScriptProcessorNode in Java Script (not sure how much the audio latency would benefit from that). Are those changes very complex or almost impossible or are they doable in the future?

As long as the official version combination (OF 0.11.2 and Emscripten 1.40.0) emscripten | openFrameworks only works with the issues mentioned above: Is there a known version combination that works without those issues (I am sure it was working at a certain point, but not sure what versions I was using)?

Fullscreen does work again with this change in EmscriptenExample.html (or better directly there: https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworksCompiled/project/emscripten/template.html): https://github.com/EasyRPG/Player/commit/d6f13705631d39c919e23dc27b150be6348f8d4b


<input type="button" value="Fullscreen" onclick="Module['canvas'].requestFullscreen()">

Instead of:

<input type="button" value="Fullscreen" onclick="Module.requestFullScreen(document.getElementById('pointerLock').checked, document.getElementById('resize').checked)">

Only that the mouse position is repositioned the wrong way (it does not get pointer lock and resize), it seems that the canvas is with the original size in the upper left corner…
Her an example: https://puredatagui.handmadeproductions.de/

1 Like

Thank you Jona!
Would you be able to submit a Pull Request with this change?

If not no worries we can add it to our 0.12.0 release list.

All the best,
Theo

1 Like

@theo Thank you. I do what I can to fix some things, but I have to admit I am a beginner and just dont understand everything… :wink:
The problem is that the mouse values are not updated / scaled according to the fullscreen resolution. Maybe it is possible to set the fullscreen in the html file and just update the new canvas size and position in the js file?
This seems to be the problem: “When using the newer constants we run into this issue with the emscripten generated html. And as the issues describe below after hitting the fullscreen button I am now getting a canvas of width and height of 0. I if I resize the canvas manually on the browser’s console rendering works as expected.” https://github.com/OGRECave/ogre/pull/1698#issuecomment-687988121

My personal reason why I think it would be great to fix these things is that I want to build audiovisual stuff with Pure Data / Ofelia for the web. Also experimented a bit with webMIDI which should not be to hard to implement it properly. Here is a prototype for that: https://pdmiditest2.handmadeproductions.de/

It was possible to fix some of the issues: https://github.com/openframeworks/openFrameworks/issues/6758

1 Like

Since most of the other issues are solved, I would be glad to know if it could be possible to reduce audio latency somehow. It´s not that bad, but depending on the browser and computer power it can be recognizable (a buffer size of 4096 is quite a save value). I am thinking of replacing ScriptProcessorNode with AudioWorkletNode and AudioWorkletProcessor, so that audio runs in a seperate thread, but had no sucess with my attempts. Could this be a realistic approach or is there another way to improve latency for OF and Emscripten? Or is it already the best possible latency?

Now OF works with the latest Emscripten version: https://github.com/openframeworks/openFrameworks/issues/6781

3 Likes