ITADN

Having issues with loading .wasm files in benchmarks

#267Opendsafa 创建于 2024-08-26
D
dsafacommented
I'm interested in running some code that uses wasm, but when running the benchmarks, it throws compile errors. For example: ``` Uncaught CompileError: WebAssembly.instantiateStreaming(): section (code 1, "Type") extends past end of the module (length 9396207, remaining bytes 1347243) @+8 ``` Looking at the network tab and downloading the wasm binary from there, it is different than the file that is located in node_modules, so it seems like its being modified somewhere. Here is a small test case index.html ``` <script type="module"> import * as bench from '/bench.js'; const brotli = await import("brotli-wasm/index.web.js").then(m => m.default); const textEncoder = new TextEncoder(); const input = 'some input'; const uncompressedData = textEncoder.encode(input); bench.start(); const compressedData = brotli.compress(uncompressedData); bench.stop(); </script> ``` package.json ``` { "name": "tachometer-wasm", "version": "1.0.0", "description": "", "main": "index.js", "scripts": {}, "author": "", "license": "ISC", "dependencies": { "brotli-wasm": "^3.0.1" } } ``` Reproduction steps: 1. run tachometer ./index.html Expected results: 1. No errors and benchmark should run Actual: 1. there is a CompileError thrown and the file `brotli_wasm_bg.wasm` fetched by the browser differs from the file in `node_modules\brotli-wasm\pkg.web\brotli_wasm_bg.wasm`
0 条评论