bun
bun copied to clipboard
Crash when trying to access web gpu / worker threads
How can we reproduce the crash?
setup a demo using this library https://github.com/sb2702/websr and bun will crash as soon as encoding starts
JavaScript/TypeScript code that reproduces the crash?
import WebSR from "@websr/websr";
import { useEffect, useRef } from "react";
import { toast } from "sonner";
function Upscaler() {
const gpu = useRef<GPUDevice | false | null>(null);
useEffect(() => {
const init = async () => {
try {
if (gpu.current) {
return;
}
gpu.current = await WebSR.initWebGPU();
if (!gpu) return toast.error("Browser/device doesn't support WebGPU");
const targetCanvas = document.getElementById(
"video-out"
) as HTMLCanvasElement;
const video = document.querySelector("video-in") as HTMLVideoElement;
if (!video) return;
if (!targetCanvas) return;
if (!gpu.current) return;
const websr = new WebSR({
source: video,
network_name: "anime4k/cnn-2x-s",
weights: await (await fetch("./cnn-2x-s.json")).json(),
gpu: gpu.current,
canvas: targetCanvas,
});
await websr.start();
} catch (error) {
console.log("error in init-->", error);
throw error;
}
};
}, []);
return (
<div className="w-full h-full p-10 bg-slate-200">
<video
id="video-in"
src="/sample-video.mp4"
controls
autoPlay
className="width-60 aspect-video"
/>
<canvas id="video-out" />
</div>
);
}
Relevant log output
Bun v1.1.8 (89d25807) Windows x64
Args: "C:\Users\srini\.bun\bin\bun.exe", "--bun", "vite"
Features: jsc Bun.stdin(2) Bun.stdout abort_signal dotenv http_server spawn(2) transpiler_cache(17) tsconfig(2)
Builtins: "bun:jsc" "bun:main" "node:assert" "node:buffer" "node:child_process" "node:crypto" "node:dns" "node:events" "node:fs" "node:fs/promises" "node:http" "node:https" "node:module" "node:net" "node:os" "node:path" "node:perf_hooks" "node:process" "node:querystring" "node:readline" "node:stream" "node:string_decoder" "node:tls" "node:tty" "node:url" "node:util" "node:util/types" "node:zlib" "node:worker_threads" "ws" "node:v8"
Elapsed: 8713ms | User: 609ms | Sys: 93ms
RSS: 0.77GB | Peak: 0.79GB | Commit: 5.41GB | Faults: 211651
panic(main thread): Internal assertion failure
oh no: Bun has crashed. This indicates a bug in Bun, not your code.
To send a redacted crash report to Bun's team,
please file a GitHub issue using the link below:
https://bun.report/1.1.8/wa189d2580A6pghoFglq4L+g0uIwit1F+swC02ljLw+pjeuztkegzqkek37xG2t9t1CA0eNrzzCtJLcpLzFFILC5OLSrJzM9TSEvMzCktSgUAiSkKPg
error: script "start" exited with code 3
Stack Trace (bun.report)
Bun v1.1.8 (89d2580
) on windows x86_64 [RunCommand]
panic: Internal assertion failure
-
debug.zig:373
:panicExtra
-
debug.zig:348
:panic
-
output.zig:356
:panic
-
bun.zig:3177
:assertionFailure
-
bun.zig:229
:cast
-
uv__work_done
-
??
-
uv_run
-
uws.zig:2619
:run
-
JSC__VM__holdAPILock