diff --git a/codecs/rotate/package.json b/codecs/rotate/package.json index aacccdaa..a4a5e203 100644 --- a/codecs/rotate/package.json +++ b/codecs/rotate/package.json @@ -1,7 +1,7 @@ { "name": "rotate", "scripts": { - "build": "mv rotate.{as,ts} && asc rotate.ts -b rotate.wasm --validate -O3 && mv rotate.{ts,as}" + "build": "mv rotate.{as,ts} && asc rotate.ts -b rotate.wasm --validate -O3 --importMemory && mv rotate.{ts,as}" }, "devDependencies": { "assemblyscript": "github:AssemblyScript/assemblyscript" diff --git a/codecs/rotate/rotate.wasm b/codecs/rotate/rotate.wasm index 3b58861b..9579e1fe 100644 Binary files a/codecs/rotate/rotate.wasm and b/codecs/rotate/rotate.wasm differ diff --git a/src/codecs/rotate/processor.ts b/src/codecs/rotate/processor.ts index 7119bae6..4cd953f3 100644 --- a/src/codecs/rotate/processor.ts +++ b/src/codecs/rotate/processor.ts @@ -11,8 +11,12 @@ export async function rotate( const numPagesNeeded = Math.ceil(bytesPerImage * 2 / (64 * 1024)); const { instance } = (await (WebAssembly as any).instantiateStreaming( fetch(wasmUrl), + { + env: { + memory: new WebAssembly.Memory({ initial: numPagesNeeded }), + }, + }, )) as { instance: RotateModuleInstance }; - instance.exports.memory.grow(numPagesNeeded); const view = new Uint8ClampedArray(instance.exports.memory.buffer); view.set(data.data);