Another WebAssembly example: Meta tic-tac-toe

Allen Garvey allen.garvey at gmail.com
Wed Aug 22 15:09:36 UTC 2018


Cool project, and nice job on the readme as well.

On Wednesday, 22 August 2018 at 12:22:34 UTC, Dennis wrote:
> The WebAssembly version was tested in FireFox, in Chrome it 
> seems to be ~1.5x slower for some reason.

Were you using Chrome for Mac by any chance? In my testing with 
the dithering example Chrome specifically on Mac had by far the 
slowest WebAssembly implementation.


> 3. Loading WebAssembly in a way that allows for both local 
> testing and Github Pages deployment was annoying. The sample 
> code from the wiki works on FireFox both locally and online, 
> but Chrome complains you're loading a .wasm larger than 4Kb (16 
> Kb in my case) synchronously. I tried using fetch and 
> instantiateStreaming, as suggested by:
> https://developers.google.com/web/updates/2018/04/loading-wasm
> But then when testing with live-server, it would complain about 
> the request having an unknown MIME type. So I settled with an 
> asynchronous XMLHttpRequest approach that works both offline 
> and online, only for Chrome you still need live-server because 
> for security it won't load requests using 'File://'.


While instantiateStreaming is definitely the future, be aware 
that this is not supported on Safari or Edge yet. I believe it is 
technically in the spec that WebAssembly has to be served with 
application/wasm mime type for instantiateStreaming, but in my 
testing Chrome doesn't care while Firefox does. The problem is 
that most web servers now don't currently serve the correct mime 
type out of the box (such as npm httpserver or Python 
simplehttpserver) so I had to use a custom node server 
(https://github.com/allen-garvey/wasm-dither-example/commit/5cd5baf84b681074de4ee7af4c224103e17a3827 https://gist.github.com/aolde/8104861) so I could set the mime type manually before I switched to instantiate since it has wider browser support.




More information about the digitalmars-d-ldc mailing list