From 713e3e0197cdf17e82783b12131519a89b389718 Mon Sep 17 00:00:00 2001 From: yuriha-chan Date: Thu, 15 Jun 2023 22:30:08 +0900 Subject: [PATCH 1/4] Suppress ReferenceError on some environments (i.e. older iOS) --- packages/frontend/src/workers/test-webgl2.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/frontend/src/workers/test-webgl2.ts b/packages/frontend/src/workers/test-webgl2.ts index 4769524d9c..0c07094ab3 100644 --- a/packages/frontend/src/workers/test-webgl2.ts +++ b/packages/frontend/src/workers/test-webgl2.ts @@ -1,3 +1,7 @@ +if (!OffscreenCanvas) { + postMessage({ result: false }); + return; +} const canvas = new OffscreenCanvas(1, 1); const gl = canvas.getContext('webgl2'); if (gl) { From fc54e56ca70a2d7e9104aa1077a1979db98cd402 Mon Sep 17 00:00:00 2001 From: yuriha-chan Date: Thu, 15 Jun 2023 23:09:19 +0900 Subject: [PATCH 2/4] fix --- packages/frontend/src/workers/test-webgl2.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/frontend/src/workers/test-webgl2.ts b/packages/frontend/src/workers/test-webgl2.ts index 0c07094ab3..2b489062cf 100644 --- a/packages/frontend/src/workers/test-webgl2.ts +++ b/packages/frontend/src/workers/test-webgl2.ts @@ -1,11 +1,11 @@ -if (!OffscreenCanvas) { - postMessage({ result: false }); - return; -} -const canvas = new OffscreenCanvas(1, 1); -const gl = canvas.getContext('webgl2'); -if (gl) { - postMessage({ result: true }); +if (window.OffscreenCanvas) { + const canvas = new OffscreenCanvas(1, 1); + const gl = canvas.getContext('webgl2'); + if (gl) { + postMessage({ result: true }); + } else { + postMessage({ result: false }); + } } else { postMessage({ result: false }); } From 211833889883560642b87d1bb2185a9fc5be57ee Mon Sep 17 00:00:00 2001 From: yuriha-chan Date: Thu, 15 Jun 2023 23:20:27 +0900 Subject: [PATCH 3/4] fix --- packages/frontend/src/workers/test-webgl2.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/workers/test-webgl2.ts b/packages/frontend/src/workers/test-webgl2.ts index 2b489062cf..bdd582788f 100644 --- a/packages/frontend/src/workers/test-webgl2.ts +++ b/packages/frontend/src/workers/test-webgl2.ts @@ -1,4 +1,5 @@ -if (window.OffscreenCanvas) { +try { + // throw ReferenceError in Safari <= 16.3 const canvas = new OffscreenCanvas(1, 1); const gl = canvas.getContext('webgl2'); if (gl) { @@ -6,6 +7,7 @@ if (window.OffscreenCanvas) { } else { postMessage({ result: false }); } -} else { +} catch (e) { + // assert(e instanceof ReferenceError) postMessage({ result: false }); } From 68b3305a9f77d3322521c8c262e86f8ac1af4172 Mon Sep 17 00:00:00 2001 From: yuriha-chan Date: Thu, 15 Jun 2023 23:49:44 +0900 Subject: [PATCH 4/4] lint --- packages/frontend/src/workers/test-webgl2.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend/src/workers/test-webgl2.ts b/packages/frontend/src/workers/test-webgl2.ts index bdd582788f..5027fa0784 100644 --- a/packages/frontend/src/workers/test-webgl2.ts +++ b/packages/frontend/src/workers/test-webgl2.ts @@ -7,7 +7,7 @@ try { } else { postMessage({ result: false }); } -} catch (e) { +} catch (err) { // assert(e instanceof ReferenceError) postMessage({ result: false }); }