Fix offscreencanvas undefined (#88)

* Suppress ReferenceError on some environments (i.e. older iOS)

* fix

* fix

* lint

---------

Co-authored-by: yuriha-chan <yuriha.tsuchiura@gmail.com>
This commit is contained in:
riku6460 2023-06-16 14:33:13 +09:00 committed by GitHub
parent e88617e3c3
commit 91af2d7b06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -1,3 +1,5 @@
try {
// throw ReferenceError in Safari <= 16.3
const canvas = new OffscreenCanvas(1, 1);
const gl = canvas.getContext('webgl2');
if (gl) {
@ -5,3 +7,7 @@ if (gl) {
} else {
postMessage({ result: false });
}
} catch (err) {
// assert(e instanceof ReferenceError)
postMessage({ result: false });
}