Giter Club home page Giter Club logo

Comments (6)

mithrendal avatar mithrendal commented on June 16, 2024

I build as described in instructions above (2.)

and it complains

[ 99%] Linking CXX executable vAmiga.html
wasm-ld: error: --shared-memory is disallowed by SDL_atomic.o because it was not compiled with 'atomics' or 'bulk-memory' features.

it seems that the SDL2 port is not build with compiler/linker flag -sWASM_WORKERS

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 ?

emsdk/upstream/emscripten/tools/ports/sdl2.py

from vamigaweb.

mithrendal avatar mithrendal commented on June 16, 2024

did a embuilder clear sdl2 to clear the sdl2 port

and patched the necessary flag into emsdk/upstream/emscripten/tools/ports/sdl2.py


command = [shared.EMCC,
                 '-sUSE_SDL=0',
                 '-c', os.path.join(ports.get_dir(), 'sdl2', SUBDIR, 'src', src),
                 '-o', o, '-I' + ports.get_include_dir('SDL2'),
                 '-O2', '-w','-sWASM_WORKERS']

now it compiles and links without error ...

when I run it says it doesn't know SharedArrayBuffer

vAmiga.js:566 Uncaught ReferenceError: SharedArrayBuffer is not defined
    at vAmiga.js:566:40

maybe now it needs COOP and COEP response headers?

from vamigaweb.

mithrendal avatar mithrendal commented on June 16, 2024

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
at vAmiga.js:6100:20

something is wrong with SDL ... I guess it can not be compiled with -sWASM_WORKERS...

maybe we should go another way
i.e. remove all sdl2 stuff from c++ and rewrite it in javascript

from vamigaweb.

mithrendal avatar mithrendal commented on June 16, 2024

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

image

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 -sWASM_WORKERS option ... maybe a bug there we will see.

from vamigaweb.

mithrendal avatar mithrendal commented on June 16, 2024

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
https://ringbuf-js.netlify.app/example/main-thread-to-audioworklet/

from vamigaweb.

mithrendal avatar mithrendal commented on June 16, 2024

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.

#to build a worker built 
#1.set thread_type to "worker"
#2.go to the sw.js and set needs_shared_array_buffer=true
set(thread_type "worker")

from vamigaweb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.