Rillke / flac.js

JavaScript FLAC encoder, decoder

Home Page:https://blog.rillke.com/flac.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can someone explain the difference between asm and wasm files

TenEniunlsl opened this issue · comments

Hi,

first things first cool thing, thanks

I have implemented it in a Chrome Extension with some other Projects to convert Soundfiles
While i implementing i have get some problems with the files under wasm but the files under asm run nicely

For another Project i have started to work on Webassembly first time and so it would help me, if someone explains the difference and how they get created

Thanks

The answers to this question at SO do better than I could.

Basically the asm.js version of flac.js uses (a subset of) plain JS code while wasm is binary and either needs to be understood by the browser executing it or a polyfill (a script that reads the binary wasm and transforms it to JS instructions) needs to be used. Nowadays nearly all browsers support wasm out-of-the-box so maybe it's some mime-type or loading issue. Make sure the file can be loaded corrctly by your Chrome Extension. I gave them a .png file extension because this ensures binary encoding to be set without any compression attempts by most browsers /CDNs/ Hosters. Maybe this is causing trouble in Chrome Extensions.

How creating WASM is done depends on what source code you'd like to get in JS. For C and C++ code, for instance, you can use Emscripten. The more strange APIs or files the C code reads and writes, the more work you'll likely have.

Ah thats the Polyfill version, I understand, Thanks

The Problem wasn't loading, the Problem was to have the rights to Eval the WASM, so my hope was to find a solution to load it without

"content_security_policy": {
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'"
},

in my manifest File

Like in JS, you can load code by <script> or by eval('script text')
JS Eval is forbidden in a Chrome extension by the way

Thanks again

Ok after my last Post i have found a solution with sandboxed context and have tried it with your code and do some measurements , asm is faster than wasm thats strange

A Note for me Sandboxed hasn't SharedArrayBuffer