-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
isolate mainloop into a webworker #124
Comments
I build as described in instructions above (2.) and it complains
it seems that the SDL2 port is not build with compiler/linker flag how to patch / add the missing flag ? We have to find the build script I searched the system and found this ... maybe it is the build script and we can add the missing flag in it ?
|
did a and patched the necessary flag into
now it compiles and links without error ... when I run it says it doesn't know SharedArrayBuffer
maybe now it needs COOP and COEP response headers? |
I did the step 1) to add the needed headers in the service worker now it knows SharedArrayBuffer ! Next complaint is Uncaught ReferenceError: _eglWaitClient is not defined something is wrong with SDL ... I guess it can not be compiled with -sWASM_WORKERS... maybe we should go another way |
all sdl2 program logic has been removed ... a new web worker thread has been created the vAmigaCore seems to like its new home and runs fine in the separate worker thread see here the main thread is doing nothing now because I have still to reimplement the SDL render logic in javascript... For this result I had to set the Amiga RTC RealTimeClock to none ... because emscripten had problems to access the timezone of the browser when build with the |
meanwhile have it running with a native javascript rendering logic as a replacement for the sdl2 rendering API, which was not compatible with web workers. being in the mood of improving performance by exploiting the new possibilities of shared array buffers ... I found an interesting article about our current implementation of audio worklet sound processor in vAmigaWeb which is feed by postMessage calls from the main thread. https://blog.paul.cx/post/a-wait-free-spsc-ringbuffer-for-the-web/ he simply claims that with shared array buffers one can replace the postMessage method and rely on a shared array buffer based ringbuffer. This should save processing time which is currently spent for the amiga audio stream. here is a also a sample implementation using that sab based ringbuffer |
There is now a parameter in the make file which decides whether the vAmigaCore will run in a separate web worker or on the main thread.
|
all devices have at least two computing cores so why not separate the computing of the emulation into a separate worker thread and keep the main ui thread idle and therefore responsive?
since web workers and shared array buffers are supported by all major browsers as of today (shared array buffers can be used in safari 15.2 which is availabe since 9 months now).
See
https://caniuse.com/webworkers
https://caniuse.com/sharedarraybuffer
let us evaluate to use it for vAmigaWeb
two things are needed for this...
how to do this I found this article which describes how to set these headers without touching the server which we can not because we host vAmigaWeb on github.io
http://stefnotch.github.io/web/COOP%20and%20COEP%20Service%20Worker/
https://emscripten.org/docs/api_reference/wasm_workers.html
and when we are done we can compare it performance wise with the current implementation...
The text was updated successfully, but these errors were encountered: