How can I compile to WASM with a fallback to asm.js?

766 views
Skip to first unread message

Shlomi Fish

unread,
May 13, 2018, 7:07:14 AM5/13/18
to emscripte...@googlegroups.com
Hi all!

I recently converted http://fc-solve.shlomifish.org/js-fc-solve/text/ to -s
WASM=1 , but then noticed it stopped running on my Samsung Galaxy S3 phone. How
can I generate webasm code, but with a fallback to asm.js?

--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
http://www.shlomifish.org/humour/Summerschool-at-the-NSA/

The Starship Enterprise motto is going to change to “To boldly go where only
Chuck Norris has gone before”.
http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

Alon Zakai

unread,
May 13, 2018, 11:06:24 AM5/13/18
to emscripten-discuss
Details are here:


But please note as it says there that a single build with a fallback will lose performance. Two separate builds avoids that.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shlomi Fish

unread,
May 13, 2018, 11:30:41 AM5/13/18
to Alon Zakai, emscripte...@googlegroups.com
Hi Alon!

On Sun, 13 May 2018 08:06:22 -0700
Alon Zakai <alon...@gmail.com> wrote:

> Details are here:
>
> http://kripken.github.io/emscripten-site/docs/compiling/WebAssembly.html#binaryen-methods
>
> But please note as it says there that a single build with a fallback will
> lose performance. Two separate builds avoids that.
>

I saw that, but I don't understand how to do two separate builds that result in
a .js file that tries to load one as a fallback to the other. Can you enlighten
me?

> On Sun, May 13, 2018 at 2:52 AM, Shlomi Fish <shl...@shlomifish.org> wrote:
>
> > Hi all!
> >
> > I recently converted http://fc-solve.shlomifish.org/js-fc-solve/text/ to
> > -s
> > WASM=1 , but then noticed it stopped running on my Samsung Galaxy S3
> > phone. How
> > can I generate webasm code, but with a fallback to asm.js?
> >
> > --
> > -----------------------------------------------------------------
> > Shlomi Fish http://www.shlomifish.org/
> > http://www.shlomifish.org/humour/Summerschool-at-the-NSA/
> >
> > The Starship Enterprise motto is going to change to “To boldly go where
> > only
> > Chuck Norris has gone before”.
> > — http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/
> >
> > Please reply to list if it's a mailing list post - http://shlom.in/reply .
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "emscripten-discuss" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to emscripten-disc...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
> >
>



--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
My Favourite FOSS - http://www.shlomifish.org/open-source/favourite/

The difference between America and England is that the English think 100
miles is a long distance and the Americans think 100 years is a long time.
— Source unknown, via Linux’s fortune-mod

Alon Zakai

unread,
May 13, 2018, 7:22:45 PM5/13/18
to Shlomi Fish, emscripten-discuss
Your HTML can pick which emscripten build to load, checking for the `typeof WebAssembly` for example. In other words, you'd write a few lines of JS to decide which emscripten build.

But how that best fits in to the website depends on the design, for example a game may start downloading the assets immediately if they are the same for both builds, while deciding between those two builds.

Another thing that will complicate this is new WebAssembly features, like threads or SIMD, that may require even more separate builds. Not sure yet what best practices there would be.



> > For more options, visit https://groups.google.com/d/optout.
> > 
>



--
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/

Shlomi Fish

unread,
May 14, 2018, 9:18:57 AM5/14/18
to Alon Zakai, emscripte...@googlegroups.com
On Sun, 13 May 2018 16:22:42 -0700
Alon Zakai <alon...@gmail.com> wrote:

> Your HTML can pick which emscripten build to load, checking for the `typeof
> WebAssembly` for example. In other words, you'd write a few lines of JS to
> decide which emscripten build.
>
> But how that best fits in to the website depends on the design, for example
> a game may start downloading the assets immediately if they are the same
> for both builds, while deciding between those two builds.
>
> Another thing that will complicate this is new WebAssembly features, like
> threads or SIMD, that may require even more separate builds. Not sure yet
> what best practices there would be.
>

thanks! I'll try.
> > > > email to emscripten-disc...@googlegroups.com.
> > > > For more options, visit https://groups.google.com/d/optout.
> > > >
> > >
> >
> >
> >
> > --
> > -----------------------------------------------------------------
> > Shlomi Fish http://www.shlomifish.org/
> > My Favourite FOSS - http://www.shlomifish.org/open-source/favourite/
> >
> > The difference between America and England is that the English think 100
> > miles is a long distance and the Americans think 100 years is a long time.
> > — Source unknown, via Linux’s fortune-mod
> >
> > Please reply to list if it's a mailing list post - http://shlom.in/reply .
> >
>



--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
https://github.com/shlomif/validate-your-html - Validate Your HTML

Tel Aviv, a functional definition: free parking space‐free space.
— Shachar Shemesh ( http://blog.shemesh.biz/?p=435 )
Reply all
Reply to author
Forward
0 new messages