From 91af2d7b068999829ba692eab9803d8417f6d918 Mon Sep 17 00:00:00 2001 From: riku6460 <17585784+riku6460@users.noreply.github.com> Date: Fri, 16 Jun 2023 14:33:13 +0900 Subject: [PATCH] Fix offscreencanvas undefined (#88) * Suppress ReferenceError on some environments (i.e. older iOS) * fix * fix * lint --------- Co-authored-by: yuriha-chan --- packages/frontend/src/workers/test-webgl2.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/frontend/src/workers/test-webgl2.ts b/packages/frontend/src/workers/test-webgl2.ts index 4769524d9c..5027fa0784 100644 --- a/packages/frontend/src/workers/test-webgl2.ts +++ b/packages/frontend/src/workers/test-webgl2.ts @@ -1,7 +1,13 @@ -const canvas = new OffscreenCanvas(1, 1); -const gl = canvas.getContext('webgl2'); -if (gl) { - postMessage({ result: true }); -} else { +try { + // throw ReferenceError in Safari <= 16.3 + const canvas = new OffscreenCanvas(1, 1); + const gl = canvas.getContext('webgl2'); + if (gl) { + postMessage({ result: true }); + } else { + postMessage({ result: false }); + } +} catch (err) { + // assert(e instanceof ReferenceError) postMessage({ result: false }); }