fix: stabilize web loading and paper rendering
This commit is contained in:
parent
fe49cc8eb5
commit
bca65600cd
25 changed files with 109 additions and 62 deletions
|
|
@ -3,9 +3,16 @@ import init, { parse_document } from "./worker_pkg/ocs_web_worker.js";
|
|||
const ready = init();
|
||||
|
||||
self.onmessage = async ({ data }) => {
|
||||
let stage = "initialize worker";
|
||||
try {
|
||||
await ready;
|
||||
const encoded = parse_document(data.name, new Uint8Array(data.bytes));
|
||||
const encoded = parse_document(
|
||||
data.name,
|
||||
new Uint8Array(data.bytes),
|
||||
(next) => {
|
||||
stage = next;
|
||||
},
|
||||
);
|
||||
// wasm-bindgen returns a view into WebAssembly.Memory. Copy to a standalone
|
||||
// ArrayBuffer before transferring it, otherwise the worker's wasm memory
|
||||
// itself would be detached.
|
||||
|
|
@ -14,7 +21,9 @@ self.onmessage = async ({ data }) => {
|
|||
} catch (error) {
|
||||
self.postMessage({
|
||||
ok: false,
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
error: `${stage}: ${
|
||||
error instanceof Error ? error.stack || error.message : String(error)
|
||||
}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue