From 8609cda0d0109a34e245766129a60d08158aaea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 25 Jan 2021 11:18:48 +0100 Subject: [PATCH 1/2] Add a parameter to allow changing phaser renderer Recently, some Macs have been crashing running WorkAdventure. Hard to say if this is related to Phaser 3.50 upgrade or to the new MacOS version. It happens mostly on Mac Air and might be related to WebGL rendering. This commit allows to switch to CANVAS renderer by adding `?phaserMode=canvas` in the URL --- front/src/index.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/front/src/index.ts b/front/src/index.ts index acf66cf8..e2b636d1 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -53,8 +53,28 @@ const fps : Phaser.Types.Core.FPSConfig = { smoothStep: false } +// the ?phaserMode=canvas parameter can be used to force Canvas usage +let params = new URLSearchParams(document.location.search.substring(1)); +let phaserMode = params.get("phaserMode"); +let mode: number; +switch (phaserMode) { + case 'auto': + case null: + mode = Phaser.AUTO; + break; + case 'canvas': + mode = Phaser.CANVAS; + break; + case 'webgl': + mode = Phaser.WEBGL; + break; + default: + throw new Error('phaserMode parameter must be one of "auto", "canvas" or "webgl"'); +} + + const config: GameConfig = { - type: Phaser.AUTO, + type: mode, title: "WorkAdventure", width: width / RESOLUTION, height: height / RESOLUTION, From c2c8680dae43b5c0c05366b5e2317d720fcc5e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 25 Jan 2021 12:02:00 +0100 Subject: [PATCH 2/2] Fix linting --- front/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front/src/index.ts b/front/src/index.ts index e2b636d1..b9a00731 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -54,8 +54,8 @@ const fps : Phaser.Types.Core.FPSConfig = { } // the ?phaserMode=canvas parameter can be used to force Canvas usage -let params = new URLSearchParams(document.location.search.substring(1)); -let phaserMode = params.get("phaserMode"); +const params = new URLSearchParams(document.location.search.substring(1)); +const phaserMode = params.get("phaserMode"); let mode: number; switch (phaserMode) { case 'auto':