From d4de7f5df3c56e6301b75cb4ff0c571e556fcfe6 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Thu, 2 May 2019 13:29:25 +0100 Subject: [PATCH] Delay creating the `Favico` instance This avoids a canvas permission prompt from appearing on page load for users in Firefox's resist fingerprinting mode. The prompt will still happen once you log in and receive a notification, but at least this prevents it from happening during the initial app experience. Fixes https://github.com/vector-im/riot-web/issues/9605 --- src/vector/platform/VectorBasePlatform.js | 25 ++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/vector/platform/VectorBasePlatform.js b/src/vector/platform/VectorBasePlatform.js index cfdeeacbe4..c10c0accd3 100644 --- a/src/vector/platform/VectorBasePlatform.js +++ b/src/vector/platform/VectorBasePlatform.js @@ -39,14 +39,7 @@ export default class VectorBasePlatform extends BasePlatform { constructor() { super(); - // The 'animations' are really low framerate and look terrible. - // Also it re-starts the animation every time you set the badge, - // and we set the state each time, even if the value hasn't changed, - // so we'd need to fix that if enabling the animation. - this.favicon = new Favico({animation: 'none'}); this.showUpdateCheck = false; - this._updateFavicon(); - this.startUpdateCheck = this.startUpdateCheck.bind(this); this.stopUpdateCheck = this.stopUpdateCheck.bind(this); } @@ -55,6 +48,24 @@ export default class VectorBasePlatform extends BasePlatform { return 'Vector Base Platform'; // no translation required: only used for analytics } + /** + * Delay creating the `Favico` instance until first use (on the first notification) as + * it uses canvas, which can trigger a permission prompt in Firefox's resist + * fingerprinting mode. + * See https://github.com/vector-im/riot-web/issues/9605. + */ + get favicon() { + if (this._favicon) { + return this._favicon; + } + // The 'animations' are really low framerate and look terrible. + // Also it re-starts the animation every time you set the badge, + // and we set the state each time, even if the value hasn't changed, + // so we'd need to fix that if enabling the animation. + this._favicon = new Favico({ animation: 'none' }); + return this._favicon; + } + _updateFavicon() { try { // This needs to be in in a try block as it will throw