Compresses the wasm binary to reduce its size when hosted#8
Compresses the wasm binary to reduce its size when hosted#8CharlVS wants to merge 6 commits intoKomodo-Community:devfrom
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| kdf._isInitializing = true; | ||
| kdf._initPromise = init() | ||
| const gzipWasmBinPath = "../kdf/bin/kdflib_bg.wasm.gz" | ||
| const gzipKdfBinUrl = new URL(gzipWasmBinPath, import.meta.url); | ||
| const kdfBinBuffer = await loadCompressedWasm(gzipKdfBinUrl); | ||
|
|
There was a problem hiding this comment.
Reset init flag when compressed wasm fetch fails
If loadCompressedWasm throws (e.g., missing kdflib_bg.wasm.gz or no DecompressionStream support), the error occurs before _initPromise is assigned, so _isInitializing remains true and no catch handler clears it. Subsequent init_wasm calls hit the _isInitializing branch that polls for _initPromise and will wait forever, leaving the KDF unusable after a single fetch failure.
Useful? React with 👍 / 👎.
| // Read, compress, and write | ||
| final wasmBytes = await entity.readAsBytes(); | ||
| final originalSize = wasmBytes.length; | ||
| final compressedBytes = gzip.encode(wasmBytes); |
There was a problem hiding this comment.
Add gzip import for wasm compression
The new compression branch calls gzip.encode(wasmBytes) but this file only imports dart:io; the gzip codec is defined in dart:convert, so this will not compile (Undefined name 'gzip') and the build step fails before copying assets. Import the proper codec or qualify it correctly.
Useful? React with 👍 / 👎.
Copied from upstream PR GLEECBTC#221
Compresses the wasm binary to reduce its size when hosted.