diff --git a/.env.template b/.env.template index a9ae63d7..4ba9bcec 100644 --- a/.env.template +++ b/.env.template @@ -10,6 +10,8 @@ START_ROOM_URL=/_/global/maps.workadventure.localhost/Floor0/floor0.json # If you are using Coturn, this is the value of the "static-auth-secret" parameter in your coturn config file. # Keep empty if you are sharing hard coded / clear text credentials. TURN_STATIC_AUTH_SECRET= +DISABLE_NOTIFICATIONS=true +SKIP_RENDER_OPTIMIZATIONS=false # The email address used by Let's encrypt to send renewal warnings (compulsory) ACME_EMAIL= diff --git a/docker-compose.single-domain.yaml b/docker-compose.single-domain.yaml index 81305671..345ccf8d 100644 --- a/docker-compose.single-domain.yaml +++ b/docker-compose.single-domain.yaml @@ -33,6 +33,8 @@ services: STARTUP_COMMAND_1: ./templater.sh STARTUP_COMMAND_2: yarn install TURN_SERVER: "turn:localhost:3478,turns:localhost:5349" + DISABLE_NOTIFICATIONS: "$DISABLE_NOTIFICATIONS" + SKIP_RENDER_OPTIMIZATIONS: "$SKIP_RENDER_OPTIMIZATIONS" # Use TURN_USER/TURN_PASSWORD if your Coturn server is secured via hard coded credentials. # Advice: you should instead use Coturn REST API along the TURN_STATIC_AUTH_SECRET in the Back container TURN_USER: "" diff --git a/docker-compose.yaml b/docker-compose.yaml index cea1bc03..1c1bcb8f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -33,6 +33,8 @@ services: STARTUP_COMMAND_2: yarn install STUN_SERVER: "stun:stun.l.google.com:19302" TURN_SERVER: "turn:coturn.workadventure.localhost:3478,turns:coturn.workadventure.localhost:5349" + DISABLE_NOTIFICATIONS: "$DISABLE_NOTIFICATIONS" + SKIP_RENDER_OPTIMIZATIONS: "$SKIP_RENDER_OPTIMIZATIONS" # Use TURN_USER/TURN_PASSWORD if your Coturn server is secured via hard coded credentials. # Advice: you should instead use Coturn REST API along the TURN_STATIC_AUTH_SECRET in the Back container TURN_USER: "" diff --git a/front/src/Enum/EnvironmentVariable.ts b/front/src/Enum/EnvironmentVariable.ts index b5de23d5..685b3c17 100644 --- a/front/src/Enum/EnvironmentVariable.ts +++ b/front/src/Enum/EnvironmentVariable.ts @@ -2,9 +2,10 @@ const DEBUG_MODE: boolean = process.env.DEBUG_MODE == "true"; const START_ROOM_URL : string = process.env.START_ROOM_URL || '/_/global/maps.workadventure.localhost/Floor0/floor0.json'; const PUSHER_URL = process.env.PUSHER_URL || '//pusher.workadventure.localhost'; const UPLOADER_URL = process.env.UPLOADER_URL || '//uploader.workadventure.localhost'; -const ADMIN_URL = process.env.ADMIN_URL || "//workadventure.localhost"; const STUN_SERVER: string = process.env.STUN_SERVER || "stun:stun.l.google.com:19302"; const TURN_SERVER: string = process.env.TURN_SERVER || ""; +const SKIP_RENDER_OPTIMIZATIONS: boolean = !!(process.env.SKIP_RENDER_OPTIMIZATIONS); +const DISABLE_NOTIFICATIONS: boolean = !!(process.env.DISABLE_NOTIFICATIONS); const TURN_USER: string = process.env.TURN_USER || ''; const TURN_PASSWORD: string = process.env.TURN_PASSWORD || ''; const JITSI_URL : string|undefined = (process.env.JITSI_URL === '') ? undefined : process.env.JITSI_URL; @@ -19,9 +20,10 @@ export const isMobile = ():boolean => ( ( window.innerWidth <= 800 ) || ( window export { DEBUG_MODE, START_ROOM_URL, + SKIP_RENDER_OPTIMIZATIONS, + DISABLE_NOTIFICATIONS, PUSHER_URL, UPLOADER_URL, - ADMIN_URL, POSITION_DELAY, MAX_EXTRAPOLATION_TIME, STUN_SERVER, diff --git a/front/src/Phaser/Game/DirtyScene.ts b/front/src/Phaser/Game/DirtyScene.ts index 27ebd3cb..e44ce07b 100644 --- a/front/src/Phaser/Game/DirtyScene.ts +++ b/front/src/Phaser/Game/DirtyScene.ts @@ -3,6 +3,7 @@ import GameObject = Phaser.GameObjects.GameObject; import Events = Phaser.Scenes.Events; import AnimationEvents = Phaser.Animations.Events; import StructEvents = Phaser.Structs.Events; +import {SKIP_RENDER_OPTIMIZATIONS} from "../../Enum/EnvironmentVariable"; /** * A scene that can track its dirty/pristine state. @@ -19,7 +20,7 @@ export abstract class DirtyScene extends ResizableScene { * Note: this does not work with animations from sprites inside containers. */ protected trackDirtyAnims(): void { - if (this.isAlreadyTracking) { + if (this.isAlreadyTracking || SKIP_RENDER_OPTIMIZATIONS) { return; } this.isAlreadyTracking = true; diff --git a/front/src/Phaser/Game/Game.ts b/front/src/Phaser/Game/Game.ts index 50bfb17a..c26d07d7 100644 --- a/front/src/Phaser/Game/Game.ts +++ b/front/src/Phaser/Game/Game.ts @@ -1,3 +1,5 @@ +import {SKIP_RENDER_OPTIMIZATIONS} from "../../Enum/EnvironmentVariable"; + const Events = Phaser.Core.Events; /** @@ -35,7 +37,7 @@ export class Game extends Phaser.Game { eventEmitter.emit(Events.POST_STEP, time, delta); // This "if" is the changed introduced by the new "Game" class to avoid rendering unnecessarily. - if (this.isDirty()) { + if (SKIP_RENDER_OPTIMIZATIONS || this.isDirty()) { const renderer = this.renderer; // Run the Pre-render (clearing the canvas, setting background colors, etc) diff --git a/front/src/Phaser/UserInput/UserInputManager.ts b/front/src/Phaser/UserInput/UserInputManager.ts index 073244d2..70bb9b1b 100644 --- a/front/src/Phaser/UserInput/UserInputManager.ts +++ b/front/src/Phaser/UserInput/UserInputManager.ts @@ -173,7 +173,7 @@ export class UserInputManager { } destroy(): void { - this.joystick.destroy(); + this.joystick?.destroy(); } private initMouseWheel() { diff --git a/front/src/WebRtc/MediaManager.ts b/front/src/WebRtc/MediaManager.ts index 0f88e743..b7594670 100644 --- a/front/src/WebRtc/MediaManager.ts +++ b/front/src/WebRtc/MediaManager.ts @@ -5,6 +5,7 @@ import type {UserInputManager} from "../Phaser/UserInput/UserInputManager"; import {localUserStore} from "../Connexion/LocalUserStore"; import type {UserSimplePeerInterface} from "./SimplePeer"; import {SoundMeter} from "../Phaser/Components/SoundMeter"; +import {DISABLE_NOTIFICATIONS} from "../Enum/EnvironmentVariable"; declare const navigator:any; // eslint-disable-line @typescript-eslint/no-explicit-any @@ -856,7 +857,7 @@ export class MediaManager { public getNotification(){ //Get notification - if (window.Notification && Notification.permission !== "granted") { + if (!DISABLE_NOTIFICATIONS && window.Notification && Notification.permission !== "granted") { Notification.requestPermission().catch((err) => { console.error(`Notification permission error`, err); }); diff --git a/front/webpack.config.ts b/front/webpack.config.ts index fc32aaea..e3568544 100644 --- a/front/webpack.config.ts +++ b/front/webpack.config.ts @@ -79,6 +79,8 @@ module.exports = { }), new webpack.EnvironmentPlugin({ 'API_URL': null, + 'SKIP_RENDER_OPTIMIZATIONS': false, + 'DISABLE_NOTIFICATIONS': false, 'PUSHER_URL': undefined, 'UPLOADER_URL': null, 'ADMIN_URL': null,