mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-15 01:59:57 +00:00
Rework fallback for postMessage issue
Now initialise all workers with module+memory separately, and then instead of using postMessage to send thread pointers, push them into a crossbeam-deque on the Rust side. Rayon already depends on crossbeam-dequeue, so we're not even adding another dependency, and this model allows us to push "tasks" (thread pointers) on the main thread and pop them on worker threads in arbitrary order without sacrificing correctness.
This commit is contained in:
committed by
Ingvar Stepanyan
parent
4c658b79ef
commit
0747d2c419
@@ -1,7 +1,7 @@
|
||||
// @ts-ignore
|
||||
import { optimise } from '../../../codecs/oxipng/spawn.js';
|
||||
import optimiser from '../../../codecs/oxipng/spawn.js';
|
||||
import { EncodeOptions } from './encoder-meta';
|
||||
|
||||
export async function compress(data: ArrayBuffer, options: EncodeOptions): Promise<ArrayBuffer> {
|
||||
return (await optimise(new Uint8Array(data), options.level)).buffer;
|
||||
return (await optimiser).optimise(new Uint8Array(data), options.level).buffer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user