Compare commits

..

1 Commits

Author SHA1 Message Date
caelum0x
249da17b3b fix(vrm): surface WebGL context-creation failures via the error boundary
viewer.setup(canvas) constructs THREE.WebGLRenderer, whose constructor
throws synchronously when WebGL context creation fails (no GPU, headless
Chrome, hardware acceleration disabled, locked-down corporate browsers,
and link-preview/crawler bots that render pages for og:image/og:video).

Because the Promise executor here is itself async, and await
viewer.setup(canvas) sat OUTSIDE the try/catch, that throw never reached
this Promise's own reject() — it became a silently discarded unhandled
rejection of the executor's own (nobody-awaited) return value, a classic
new Promise(async () => {}) anti-pattern. So neither .then() nor
.catch() on the outer promise ever ran, isLoading never flipped, and the
page was left on a permanent blank loading overlay with no error shown.

Fix: move the await inside the try block so a setup failure now
correctly flows through reject(e) -> the existing .catch() handler,
which already calls setLoadingError(true) and renders the component's
own 'Error loading VRM model...' fallback.

Found and verified while building an app on top of this component
(https://kamiko.fun, a live AI VTuber) — the identical pattern was
reproduced with a real no-WebGL headless browser session, fixed the
same way, and confirmed live before/after (stuck blank overlay -> real
error UI). Porting the same fix back here since the bug is in this
file, not anything downstream added.
2026-10-29 02:49:08 +03:00

View File

@ -28,9 +28,9 @@ export default function VrmViewer({ chatMode }: { chatMode: boolean }) {
(canvas: HTMLCanvasElement) => {
if (canvas && (!isVrmLocal || !isLoadingVrmList)) {
new Promise(async (resolve, reject) => {
await viewer.setup(canvas);
try {
await viewer.setup(canvas);
const currentVrm = getCurrentVrm();
if (!currentVrm) {
setIsLoading(true);