nannou-org / nannou

A Creative Coding Framework for Rust.
https://nannou.cc/
5.98k stars 304 forks source link

wasm? #657

Open AJTJ opened 3 years ago

AJTJ commented 3 years ago

It seems like wgpu is running in the browser as per: https://github.com/gfx-rs/wgpu-rs/pull/193 , does nannou allow you to run its sketches/apps in the browser yet?

mitchmindtree commented 3 years ago

It should be very close now, I don't think there should be any more major blockers! Just a matter of someone taking the time to have a crack at it. There will likely be a few small unforeseen tweaks or changes that we or our dependencies need to make to be totally compatible, but no deal-breakers that I can think of now that wgpu is running in the browser.

Also discussed in #475

AJTJ commented 3 years ago

That's promising to hear, so who do we need to poke to get this happening?

Woyten commented 3 years ago

I think the conrod suite 0.71 is required. They closed https://github.com/PistonDevelopers/conrod/issues/1381 recently, so if we asked them kindly, they might release version 0.71.

AJTJ commented 3 years ago

@Woyten I'm relatively new to rust/nannou, but let me know if there's something I can help with in this regard. I'm in the process of getting into some creative projects and would like to be able to present some interactive WASM projects with nannou on my portfolio website.

Woyten commented 3 years ago

@AJTJ I am working on a microtonal modular synthesizer/sequencer/audio workstation which I hope to be able to deploy as a web app soon. Since, as of now, Nannou isn't wasm-compatible the graphical interface of the synthesizer isn't running on the web yet. I managed, however, to get the audio model running which can be explored here: http://woyten.github.io/microwave/?arg=steps&arg=1:22:2. The given URL will create a synthesizer instance tuned to 22 notes per octave as an example.

There are a lot of things that can be done to support https://github.com/woyten/tune many of which I did not create an issue for. If there is some interest in contributing to the lib or the synth I will create more issues as an orientation.

AJTJ commented 3 years ago

@Woyten very cool project. I would be interested in helping a bit here and there if you clarified some issues. Any future goals for this project? Product? Copyleft?

AJTJ commented 3 years ago

@mitchmindtree is there something I can do to help wasm move forwards? If you could point me at some achievable issues I'd love to help out.

mitchmindtree commented 3 years ago

Here are some thoughts on how I would go about getting this working.

I'd start by trying to get a simple-as-possible wgpu-rs example that has already been demonstrated to work well in the browser locally, to verify that it's at least possible on my setup. Keep in mind that the current nannou master uses wgpu 0.5, so it might be worth testing the wgpu example with 0.5 too. Alternatively, if it seems like wgpu 0.6 is needed, #655 looks to be most of the way there (haven't had a chance to do a full review just yet).

Once working, I would try to make a copy of the example, and add nannou as a dependency. Doing this should include nannou in the build process for the WASM target, and any remaining issues should be raised by the compiler as an error. There shouldn't be any major blockers, but this will help to guide towards what remains that needs addressing.

The wgpu-users channel on Matrix is also full of very helpful folks - I highly recommend hanging out there while hacking on this :) They've been a great help in landing wgpu in nannou in general.

I hope some of this helps a little bit!

Woyten commented 3 years ago

@AJTJ I ceated some new issues that I think might be good for "beginners".

In order to not misuse this issue we could continue the discussion here! :smiley:

AJTJ commented 3 years ago

@mitchmindtree will look into this

AJTJ commented 3 years ago

@mitchmindtree so it seems like this issue is rather deep

Trying to get the wgpu examples running is proving challenging.

Here are the examples: https://wgpu.rs/examples/?example=hello-triangle

I've only attempted to get it working with Firefox Nightly, setting the various flags as required here: https://github.com/gpuweb/gpuweb/wiki/Implementation-Status#firefox

But it seems to only want to crash.

Here are similar bug reports of this issue with Firefox:

https://bugzilla.mozilla.org/buglist.cgi?product=Core&component=Graphics%3A%20WebGPU

This is where this is at currently.

mitchmindtree commented 3 years ago

Thanks for digging into this @AJTJ! Ahh I thought WebGPU in browsers might have progressed a bit further by now, but I guess it's still early days. Perhaps we can at least prepare using firefox nightly best we can in the meantime.

AJTJ commented 3 years ago

@mitchmindtree I saw that you merged this 20 days ago https://github.com/nannou-org/nannou/commit/1ff57265b6226b4eb6bf2155fdb25b38e3da0111

Does this move us forwards somehow?

Hope all is well.

Woyten commented 3 years ago

@AJTJ Upgrading to wgpu-0.6 is not sufficient. See my comment.

We need at least wgpu-0.7.0 and some new not yet published conrod_wgpu Version that depends on wgpu-0.7.0.

A step towards making nannou compile against wasm is #715.

yutannihilation commented 3 years ago

some new not yet published conrod_wgpu Version that depends on wgpu-0.7.0.

I'll try to update it here, though I'm stuck with some cryptic error...: https://github.com/PistonDevelopers/conrod/pull/1410

AJTJ commented 3 years ago

Just want to note that @mitchmindtree and @yutannihilation did update conrod wgpu to 0.7 at https://github.com/PistonDevelopers/conrod/pull/1413

Steps towards wasm :)

AJTJ commented 3 years ago

@mitchmindtree @Woyten how goes the progress towards wasm? :) Perhaps I can look at something?

mitchmindtree commented 3 years ago

I haven't personally had a chance to dig into this yet - but I think we must be getting close. There's also a wgpu 0.8 update which I think is just about ready to merge #737 which I imagine would only take us a step closer. @Woyten pointed out some remaining required steps here, and also has a WIP PR here which they might appreciate some help with.

AJTJ commented 3 years ago

@mitchmindtree any news on this one? :)

Woyten commented 2 years ago

@AJTJ There is an update: #811

tomoyanonymous commented 1 year ago

I just made a template repo based on @Woyten 's implementation and rustwasm's template.

https://github.com/tomoyanonymous/nannou-web-template

It's working nicely both on the native app and the latest version of Chrome without any flag!

flbn commented 1 year ago

should this be closed? looks like it's working...

cxreiff commented 1 year ago

Similar template for vite: https://github.com/cxreiff/vite_nannou_template

I think it should stay open as you currently still need to pick a non-release commit that has the wasm-experimental feature- unless I'm missing something.

milgner commented 1 month ago

Looks like there are a number of issues open on the subject of WASM.

Given that this thread links to working versions, I assume that the original comments in #7 which suggest that it won't work have been superseded?

But after reading #939 I suppose that we cannot expect any stable release any time soon? I'm currently looking for a creative coding framework that runs in a browser but that isn't in JS. Rust would have been very nice as the backend which provides the data is in Rust, too, which would have enabled me to stick to one language.

tychedelia commented 1 month ago

Hi! We are currently working on #953, which will continue take some time but should improve our ability to support wasm as this is a big goal of bevy itself. So, stay tuned. :)