-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Latest Emscripten 2.0.33 works well, except file loading. [solved] #6781
Comments
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):
|
I comiled boost again, and now OF works with boost and Emscripten 2.0.33... |
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)
|
hey @Jonathhhan Thanks for all this. |
@roymacdonald yes, of course. I will do that the next days. |
after installing emscripten 2.0.33 I cant compile as it complains the following:
@Jonathhhan |
I was able to get it to compile. I mostly needed to recompile the core lib dependencies. |
@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... |
Sure, no problem. |
Yes, GLES2 is working now (my example https://gameoflife3d.handmadeproductions.de/ actually uses shaders for the grid). I think its part of my changes. changing this: EGLint contextAttribs[] = { EGL_CONTEXT_MAJOR_VERSION, 3, EGL_NONE, 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). |
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. |
@Jonathhhan I tried out your changes and cloned your OF repo, but it was not working. Maybe I missed something. |
@roymacdonald sorry, I dont have all the changes in my repo yet. I will tell you, if so. This is the mentioned and used Emscripten AudioWorklet branch: https://github.com/tklajnscek/emscripten/tree/worklet_support. |
@roymacdonald I made an OF AudioWorklet branch (I hope, its fine like that) that includes all updates for Emscripten 2.0.34 (and some other fixes) and for the Emscripten AudioWorklet branch: https://github.com/Jonathhhan/openFrameworks/tree/AudioWorklet
at line 291) |
@Jonathhhan awesome! I'll check it and get back with comments (and see how to make all the other audio stuff to work) |
This is the error message with the pdExample from ofxPd:
|
I got that error before and fixed it. |
@roymacdonald with your changes I get kind of a similar error as in the pdExample (but only one of them):
while undefined is
The patch loads fine, but without the audioWorklet... |
I am not even able to run the pd example as it fails compiling it, although the OF audio examples work fine. There are some issues with the ofxPd addon. Are you using a branch other than ofxPd's master? |
btw, I am using macos. i understand you use linux, right? |
yes, ubuntu 20.04. I forgot to mention, I think I use the ofxPd lib that is included in ofxOfelia and I set the inputs to 0... |
It works with -s PROXY_TO_PTHREAD=1 -s OFFSCREENCANVAS_SUPPORT=1 -s OFFSCREEN_FRAMEBUFFER=1, sadly not yet together with audioworklet yet, but it seems to be very efficient.
If I dont remove the audioworklet part with offscreen canvas I get this message (maybe because it is not possible to create a worker from a worker...):
|
And without -s PROXY_TO_PTHREAD=1 -s OFFSCREENCANVAS_SUPPORT=1 -s OFFSCREEN_FRAMEBUFFER=1 your updated files work with audioworklet if I remove:
from the generated java script file (at line 239). |
Great! |
Here is an example with |
So I am able to run the sound examples for input and output audio with graphics and all. One thing I noticed was that the files were not being able to load because of ofToDataPath was not giving the correct path.
Now I can load files yet still ofxPd gives me odd errors which dont have much info in order to debug. So, out of this I would be inclined to say that the problem lies in either ofxPd or libpd, rather than in OF as audio works well. |
Hey @Jonathhhan Trying to get C++17 in via this PR: -std=c++17 is getting past through to the compiler
but I am running into this error:
Did you ever get OF working with C++17 and not using boost for the filesystem stuff? |
Hey @ofTheo, (Its also working without audioWorklets, just need to change 1 or 2 variables...) Also updated the branch my example to show the changes: https://audiovideopdprocessing.handmadeproductions.de/ I thought about the urls that I create from JS: They maybe only work because they are send back and read from JS. And that works only for ofxEmscriptenVideoPlayer and ofxEmscriptenSoundPlayer (which is very nice, by the way...). Something like ofImage would need a different pointer (I am only guessing). Or I have to check outhow to load local files into the Emscripten filesystem and read from there (some help with that is kindly appreciated)... |
Hey @ofTheo and @roymacdonald, what do you think about my changes of the ofxEmscriptenAudioPlayer? Does it make sense?
Regarding unvoking the urls: Maybe also create an unload() method for ofxEmscriptenVideoPlayer for that? And one idea regarding drag and drop: If it would be possible to define a html drop area from OF, then drag and drop would make sense (right now it works, but only for the whole window as the drop area). |
So I added pan for audio and video... And I ask myself: Is it really necessary to create several audioContexts or would one be enough (I ask because it seems not possible to connect one node of one context to a node of another context, and for what I did one audioContext with id 0 was enough)? And a stream is created as soon as I have an And one idea regarding connecting the audio and video player to the audiostream: They could get a method like |
Hey @Jonathhhan If you do really need to use a sound stream to make it work then ofxEmscriptenSoundPlayer and ofxEmscriptenVideoPlayer should both inherit from `ofBaseSoundOutput' |
@roymacdonald you already set a float for pan, but from -1 to 1. I think in OF its 0 - 1? No problem to change that (I hope I understood it right).
|
tha works nicely. I couldnt notice any distortion while moving the pan but I just used my laptop's speakers. No headphones atm.
I see. It depends on what you want to achieve if you need to use a soundstream or not. I am not sure what would be the best option here. Maybe a hybrid, which uses the sound stream if it is connected to it, otherwise it uses what you already implemented through the audio worklet? |
@roymacdonald Yes, I already lowered the initial volume, maybe a bit too much.
That sounds good. The main problem with the audioWorklet is (in my opinion) that it relies on a non official Emscripten branch from @tklajnscek, and I dont know if it will be up to date. But we can ask the author and maybe he will update it for himself. He updated it for 3.0.1, not sure about the current and future versions. With this version it works great. |
I have some questions about the filesystem stuff: |
Hey @Jonathhhan I think there should not be a
Check this example https://github.com/openframeworks/openFrameworks/tree/master/examples/input_output/imageLoaderWebExample Let me know how it goes. |
Hey @roymacdonald thanks for the examples. that makes totally sense and would be much better than my solution. I will give it a try, but not sure if I am able implement to implement that into |
I just realized that ofSoundPlayer does not have a get duration method. which is quite strange that has not been added so far. I think that these should be Let me know if you need help implementing |
@roymacdonald would you have some time to help @Jonathhhan wrap up all the fairly clean emscripten fixes into a PR? I got C++17 working for emscripten in this PR Just needed an extra header include and the C++17 flag in the end. |
@ofTheo sure! no prob. @Jonathhhan can you please point me to the repo in which you are pushing the emscripten upgrades |
Hey @ofTheo and @roymacdonald, thats great news. I tried the url stuff from ofImage, but without luck. 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)... |
Actually the sound player works with url and local file with this methods:
Somehow it does not work for the video player... |
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. |
Hi @Jonathhhan
I will go through all the changes, updates and upgrades you have done and get back to you. |
@roymacdonald thanks a lot. And just to mention: The old |
Last update for now. The video player works now with url check (but I had to add "blob" to
And here are some of the updated examples: https://github.com/Jonathhhan/ofEmscriptenExamples
Thats nice. I can confirm that it works, just needed to add your changes from ofConstants.h, ofFileUtils.cpp and ofUtils.h... |
Here are some good news regarding the future of Emscripten and Audioworklets (at the end of the discussion): emscripten-core/emscripten#12502 (comment) |
Just found another inconsistency between |
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? |
Its Ubuntu, and I am sorry, I meant getPosition() of course... |
@roymacdonald I have the same errors as you. Could you please inform me what is it that you recompiled ? |
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 |
@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? |
@ranjithshegde ah sorry. Apothecary is an openframeworks tool for keeping track and updating the libraries it uses. It is in github.com/openframeworks/apothecary |
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)?
The text was updated successfully, but these errors were encountered: