fwcd / m1xxx

Unofficial native Mixxx builds for macOS (Apple Silicon/Intel) and Linux
Other
38 stars 7 forks source link

Port Mixxx to Emscripten/WebAssembly #69

Open fwcd opened 9 months ago

fwcd commented 9 months ago

Status

The wasm branch contains experimental forks of mixxx and vcpkg for targeting wasm32-emscripten.

You can try it out, there is a GitHub Pages-hosted build at https://fwcd.github.io/m1xxx, but be warned: It may take a while to load (the Wasm binary is ~300 MB, the assets are ~90 MB) and there is no audio (the experimental "Web Audio" backend is not functional yet, hence why it is disabled by default).

Screenshot

On the technical side, there are still some major roadblocks to be resolved:

Something to investigate would be whether we could replace -sASYNCIFY entirely with -sPROXY_TO_PTHREAD, i.e. move the "main" thread to a Web Worker where we can block synchronously. Unfortunately, there seem to be some complexities involved in making this work with Qt:

We may have to check whether setting USE_PTHREADS=1 for Qt would help here (or whether that would be redundant because our vcpkg triplet already sets -pthread).

Another option would be the recently-added C++20 co_await integration, which uses native LLVM coroutines and thus hopefully shouldn't be bound to the same limitations as Asyncify: https://github.com/emscripten-core/emscripten/issues/20413

Given that PortAudio exposes a C interface, I am not sure how well we could integrate C++ coroutines there, however.

Motivation

Being able to run Mixxx on the web would be pretty cool. Qt supports WebAssembly, we would however also have to compile all of the other dependencies. This would probably take some work, but should not be impossible.

We take a similar approach to the iOS port (#16) and use custom WASM branches for mixxx and vcpkg, along with an integration branch in m1xxx, then gradually upstream the required changes.

Porting the dependencies to WebAssembly

Porting Mixxx to WebAssembly

Upstreaming the Mixxx patches

Upstreaming the vcpkg patches

to microsoft/vcpkg

to mixxxdj/vcpkg

TBD:

to upstream projects

Nice to have

Useful resources

owlandfox commented 3 months ago

This is awesome! I suggested/requested a web version of MIxxx a couple years ago so its great to see it in progress! I see there are still a couple tasks needed to get it fully operational?

fwcd commented 3 months ago

Yes, the UI mostly works (you can try it online), the biggest missing piece is currently the Web Audio backend. Mixing that, Qt and Asyncify seems to be a lot more complicated than I had hoped for, so I've put this project on hold until Qt/Emscripten hopefully work out these interactions.

owlandfox commented 3 months ago

Wow yes it looks like its all working pretty smoothly otherwise. Hopefully they can solve this soon as I know a lot of users including me will have a great use case for Mixxx in the browser