Repository navigation
Description
It was possible to compile with the latest Emscripten, for that I had to recompile the OF libs (FreeImage or freetype for example) with the current Emscripten and made some other small changes like using c++17 and std filesystem instead of boost (boost had an undefined symbol).
I guess the issue now has to do with the glm qualifier glm::qualifier)0>&, this is the Java Script error message for the imageSubsectionExample (everything compiles fine):
imageSubsectionExample.html:1 emscripten_set_main_loop_timing: Cannot set timing mode for main loop since a main loop does not exist! Call emscripten_set_main_loop first to set one up. printErr @ imageSubsectionExample.html:1 imageSubsectionExample.html:1 Aborted(native code called abort()) printErr @ imageSubsectionExample.html:1 imageSubsectionExample.js:1 Uncaught RuntimeError: Aborted(native code called abort()) at abort (imageSubsectionExample.js:1:34496) at _abort (imageSubsectionExample.js:1:119651) at std::__2::__throw_failure(char const*) (imageSubsectionExample.wasm:0x362df2) at std::__2::__fs::filesystem::__canonical(std::__2::__fs::filesystem::path const&, std::__2::error_code*) (imageSubsectionExample.wasm:0x380f6f) at ofToDataPath(std::__2::__fs::filesystem::path const&, bool) (imageSubsectionExample.wasm:0x55a2d) at ofApp::setup() (imageSubsectionExample.wasm:0x22653) at ofNode::onParentOrientationChanged(glm::qua<float, (glm::qualifier)0>&) (imageSubsectionExample.wasm:0x4638a) at std::__2::__function::__func<std::__2::shared_ptr<of::priv::Function<ofKeyEventArgs, std::__2::recursive_mutex> > ofEvent<ofKeyEventArgs, std::__2::recursive_mutex>::make_function<ofMainLoop>(ofMainLoop*, void (ofMainLoop::*)(ofKeyEventArgs&), int)::'lambda'(void const*, ofKeyEventArgs&), std::__2::allocator<std::__2::shared_ptr<of::priv::Function<ofKeyEventArgs, std::__2::recursive_mutex> > ofEvent<ofKeyEventArgs, std::__2::recursive_mutex>::make_function<ofMainLoop>(ofMainLoop*, void (ofMainLoop::*)(ofKeyEventArgs&), int)::'lambda'(void const*, ofKeyEventArgs&)>, bool (void const*, ofKeyEventArgs&)>::operator()(void const*&&, ofKeyEventArgs&) (imageSubsectionExample.wasm:0x4c0d6) at ofEvent<ofHttpResponse, std::__2::recursive_mutex>::notify(ofHttpResponse&) (imageSubsectionExample.wasm:0x2a046) at ofCoreEvents::notifySetup() (imageSubsectionExample.wasm:0x4cb73)
Is there a way to solve whether the boost, the glm or the std filesystem issue, so that is possible to load data with OF and the latest Emscripten (everything else seems to work fine)?
Activity
Jonathhhan commentedon Nov 12, 2021
This is the Java Script error message if I compile with boost (even if there is no file to load):
And interestingly, if I compile with std filesystem and -O1 instead of -O3 the glm error is gone (which enables for example the polygonExample to work):
imageSubsectionExample.html:1 emscripten_set_main_loop_timing: Cannot set timing mode for main loop since a main loop does not exist! Call emscripten_set_main_loop first to set one up. printErr @ imageSubsectionExample.html:1 imageSubsectionExample.html:1 Aborted(native code called abort()) printErr @ imageSubsectionExample.html:1 imageSubsectionExample.js:201 Uncaught RuntimeError: Aborted(native code called abort()) at abort (imageSubsectionExample.js:1596:10) at _abort (imageSubsectionExample.js:5377:2) at void std::__2::__fs::filesystem::__throw_filesystem_error<std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >&, std::__2::__fs::filesystem::path const&, std::__2::__fs::filesystem::path const&, std::__2::error_code const&>(std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char> >&, std::__2::__fs::filesystem::path const&, std::__2::__fs::filesystem::path const&, std::__2::error_code const&) (imageSubsectionExample.wasm:0x3d5671) at std::__2::__fs::filesystem::detail::(anonymous namespace)::ErrorHandler<std::__2::__fs::filesystem::path>::report(std::__2::error_code const&) const (imageSubsectionExample.wasm:0x3d561a) at std::__2::__fs::filesystem::__canonical(std::__2::__fs::filesystem::path const&, std::__2::error_code*) (imageSubsectionExample.wasm:0x3d54df) at ofToDataPath(std::__2::__fs::filesystem::path const&, bool) (imageSubsectionExample.wasm:0x4d9d7) at ofLoadImage(ofPixels_<unsigned char>&, std::__2::__fs::filesystem::path const&, ofImageLoadSettings const&) (imageSubsectionExample.wasm:0x10179) at ofImage_<unsigned char>::load(std::__2::__fs::filesystem::path const&, ofImageLoadSettings const&) (imageSubsectionExample.wasm:0x10a8c) at ofApp::setup() (imageSubsectionExample.wasm:0x9248) at ofBaseApp::setup(ofEventArgs&) (imageSubsectionExample.wasm:0x330e2)So my question is: Is there is a way to make any of the filesystems work with this Emscripten version?
Jonathhhan commentedon Nov 12, 2021
I comiled boost again, and now OF works with boost and Emscripten 2.0.33...
Can add what I changed exactly for that, but basically I recompiled the necessary OF libs with Apothecary Emscripten 2.0.33.
Edit: Also had to change some other stuff, but now it seems to work like the last versions...
[-]Latest Emscripten 2.0.32 works well, except file loading.[/-][+]Latest Emscripten 2.0.32 works well, except file loading. [solved][/+]Jonathhhan commentedon Nov 13, 2021
Those are the additional changes (these changes need to be added, too: #6758):
library_html5video.js (remove type)
index.html (keyevents)
library_html5.js(emsdk remove __ from getBoundingClientRect)
config.emscripten.default.make (add DYNCALLS=1 and BINARYEN_EXTRA_PASSES=--one-caller-inline-max-function-size=1)
PLATFORM_LDFLAGS = -Wl,--gc-sections --preload-file bin/data@data --emrun -s DYNCALLS=1 -s MAX_WEBGL_VERSION=2 -s WEBGL2_BACKWARDS_COMPATIBILITY_EMULATION=1 -s BINARYEN_EXTRA_PASSES=--one-caller-inline-max-function-size=1[-]Latest Emscripten 2.0.32 works well, except file loading. [solved][/-][+]Latest Emscripten 2.0.33 works well, except file loading. [solved][/+]roymacdonald commentedon Nov 19, 2021
hey @Jonathhhan Thanks for all this.
Can you push to your OF fork all this changes so it is easier to check it and not having to go through all this issue and manually changing stuff.?
Jonathhhan commentedon Nov 19, 2021
@roymacdonald yes, of course. I will do that the next days.
roymacdonald commentedon Nov 19, 2021
after installing emscripten 2.0.33 I cant compile as it complains the following:
@Jonathhhan
it is not seeing ofxEmscriptenSoundStream. did you add it somewhere? the other errors are for tess2.
thanks
roymacdonald commentedon Nov 20, 2021
I was able to get it to compile. I mostly needed to recompile the core lib dependencies.
Jonathhhan commentedon Nov 21, 2021
@roymacdonald thats nice. It would be great if you can help me to get the ofxPd examples to run with Emscripten (for using it with AudioWorklets). ofxPd works for me as part of ofxOfelia with Emscripten and standalone, but somehow not with Emscripten without ofxOfelia...
roymacdonald commentedon Nov 21, 2021
Sure, no problem.
Let me get it to run the window properly. Did you manage to get GLES 2 shaders to work? I have not. I am modifying ofxAppEmscriptenWindow to make it work properly based on some examples that emscripten has.
once I get that to work it my guess is that it shouldnt be much trouble to get audio to work as I know very well how audio works within OF.
Jonathhhan commentedon Nov 21, 2021
Yes, GLES2 is working now (my example https://gameoflife3d.handmadeproductions.de/ actually uses shaders for the grid). I think its part of my changes.
#6758
changing this:
EGLint contextAttribs[] = { EGL_CONTEXT_MAJOR_VERSION, 3, EGL_NONE, EGL_NONE };
std::vector attribList =
{
EGL_RED_SIZE, EGL_DONT_CARE,
EGL_GREEN_SIZE, EGL_DONT_CARE,
EGL_BLUE_SIZE, EGL_DONT_CARE,
EGL_ALPHA_SIZE, EGL_DONT_CARE,
EGL_DEPTH_SIZE, EGL_DONT_CARE,
EGL_STENCIL_SIZE, EGL_DONT_CARE,
EGL_SAMPLE_BUFFERS, EGL_DONT_CARE,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR,
EGL_NONE
};
in https://github.com/Jonathhhan/openFrameworks/blob/master/addons/ofxEmscripten/src/ofxAppEmscriptenWindow.cpp and adding the flag -s USE_WEBGL2=1 to config.emscripten.default.mk enables webgl2 without editing any Emscripten file (in addition I use -s WEBGL2_BACKWARDS_COMPATIBILITY_EMULATION=1 for backwards compatibility with webgl1 https://emscripten.org/docs/optimizing/Optimizing-WebGL.html).
Jonathhhan commentedon Nov 21, 2021
For AudioWorklets and SharedArraybuffer all used libs (for most things boost is enough) and also OF need to be compiled with -s USE_PTHREAD=1 or multi thread support. The pthread compiled libs work also if pthread isnt used.
roymacdonald commentedon Nov 21, 2021
@Jonathhhan I tried out your changes and cloned your OF repo, but it was not working. Maybe I missed something.
Although I got it to work by changing a lot of other things and making it rely more on the emscripten functions. Maybe I messed up something when trying to get it to compile. I will go back and start over now that I have the necesary libs compiled and working. I will let you know how it goes. c
cheers
66 remaining items
Jonathhhan commentedon Feb 7, 2022
Hey @ofTheo and @roymacdonald, thats great news.
I tried the url stuff from ofImage, but without luck.
But urls do work if I replace
audioPlayer.load(ofToDataPath(fileName)withaudioPlayer.load(fileName).With the first one I can load files from the filesystem. Same for the video player.
Maybe that helps.
And I removed loadUrl()...
And here is the branch: https://github.com/Jonathhhan/openFrameworks/tree/AudioWorklet
I also made the audio context and the fft global (would also be possible to have a seperate fft for every sound id)...
I hope I didnt break too much... ;)
But I have all the older steps here if I should revert something...
And of course, take what you think makes sense and if you have any questions I am happy to answer.
Best.
Jonathhhan commentedon Feb 8, 2022
Actually the sound player works with url and local file with this methods:
Somehow it does not work for the video player...
Jonathhhan commentedon Feb 8, 2022
This works for the video player (but maybe not a nice solution):
I updated the branch, video and audio player have the method above now. This way I dont have to change a lot.
You can remove or change it if it is not save.
roymacdonald commentedon Feb 8, 2022
Hi @Jonathhhan
This is the chunk of code you need in order to tell if it is an URL or not. I think there should be an OF function wrapping this up. It can be quite handy.
I will go through all the changes, updates and upgrades you have done and get back to you.
cheers
Jonathhhan commentedon Feb 8, 2022
@roymacdonald thanks a lot. And just to mention: The old
html5audio_stream_createmethod is not implemented in my branch yet, but I guess it can be easily replaced...Without replacing it the stream works only with audioWorklet (but everything else should work independently from that).
Jonathhhan commentedon Feb 8, 2022
Last update for now. The video player works now with url check (but I had to add "blob" to
if(scheme == "http" || scheme == "https" || scheme == "blob" )). And the audio player with those 2 methods (because the url check didnt work there somehow - because the file / url is send as a std::filesystem::path and not as a std::string):And here are some of the updated examples: https://github.com/Jonathhhan/ofEmscriptenExamples
@ofTheo
Thats nice. I can confirm that it works, just needed to add your changes from ofConstants.h, ofFileUtils.cpp and ofUtils.h...
Jonathhhan commentedon Feb 15, 2022
Here are some good news regarding the future of Emscripten and Audioworklets (at the end of the discussion): emscripten-core/emscripten#12502 (comment)
Jonathhhan commentedon Mar 4, 2022
Just found another inconsistency between
ofVideoPlayerandofEmscriptenVideoPlayerwithgetDuration().With
ofVideoPlayerI get values between 0 and 1, while withofEmscriptenVideoPlayerI get the duration in seconds.roymacdonald commentedon Mar 5, 2022
duration between 0 and 1 sounds like a bug? Although what you get is dependent on the platform you are using. On which platform did you see this?
Jonathhhan commentedon Mar 5, 2022
Its Ubuntu, and I am sorry, I meant getPosition() of course...
ranjithshegde commentedon May 21, 2022
@roymacdonald I have the same errors as you. Could you please inform me what is it that you recompiled ?
roymacdonald commentedon May 21, 2022
I really cant recall. But i think that I recompiled emscripten using apothecary, maybe i had to recompile some other things using apothecary as well. That is what would make sense to me
ranjithshegde commentedon May 22, 2022
@roymacdonald Thanks for your response. Sadly I dont know what apothecary is. I checked the git repo and it seems like there are some scripts in there, specific to emscripten was just a method to install it in docker.
Could you please point me towards any resources to understand what that repo is? Or how I would use them?
roymacdonald commentedon May 22, 2022
@ranjithshegde ah sorry. Apothecary is an openframeworks tool for keeping track and updating the libraries it uses. It is in github.com/openframeworks/apothecary
Just download that repo into scripts/apothecary and run from there. What you need to do is to find the emscripten "formula", which is also inside the scripts folder and change the version to the latest one and run apothecary so it updates emscripten