nannou icon indicating copy to clipboard operation
nannou copied to clipboard

wasm?

Open AJTJ opened this issue 3 years ago • 23 comments

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?

AJTJ avatar Oct 01 '20 13:10 AJTJ

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

mitchmindtree avatar Oct 04 '20 14:10 mitchmindtree

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

AJTJ avatar Oct 04 '20 22:10 AJTJ

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.

Woyten avatar Oct 06 '20 15:10 Woyten

@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.

AJTJ avatar Oct 14 '20 17:10 AJTJ

@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.

Woyten avatar Oct 20 '20 18:10 Woyten

@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 avatar Oct 22 '20 21:10 AJTJ

@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.

AJTJ avatar Oct 23 '20 14:10 AJTJ

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!

mitchmindtree avatar Oct 23 '20 15:10 mitchmindtree

@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:

Woyten avatar Oct 24 '20 21:10 Woyten

@mitchmindtree will look into this

AJTJ avatar Oct 29 '20 22:10 AJTJ

@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.

AJTJ avatar Oct 29 '20 23:10 AJTJ

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.

mitchmindtree avatar Oct 30 '20 11:10 mitchmindtree

@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.

AJTJ avatar Mar 19 '21 16:03 AJTJ

@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.

Woyten avatar Mar 20 '21 10:03 Woyten

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

yutannihilation avatar Mar 21 '21 12:03 yutannihilation

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 avatar Apr 20 '21 13:04 AJTJ

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

AJTJ avatar May 09 '21 03:05 AJTJ

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.

mitchmindtree avatar May 22 '21 15:05 mitchmindtree

@mitchmindtree any news on this one? :)

AJTJ avatar Jul 24 '21 02:07 AJTJ

@AJTJ There is an update: #811

Woyten avatar Dec 08 '21 11:12 Woyten

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!

tomoyanonymous avatar Nov 21 '22 05:11 tomoyanonymous

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

flbn avatar Feb 03 '23 23:02 flbn

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.

cxreiff avatar Jul 01 '23 04:07 cxreiff