perf(v2): use static background SVG in Firefox to stop GPU repaint

The auth_background.svg fallback contains two infinite CSS animations.
As a full-viewport background-image under a 28px blur (and re-sampled by
every backdrop-filter surface), Firefox's WebRender re-rasterizes the
whole viewport every frame, pegging the renderer/GPU. It is worst on
pages that fall back to this art (settings, administration) since they
call setBgArt(null); other pages show static cover art.

Swap to the existing static variant in Firefox only via the
@-moz-document url-prefix() hack (the same pattern v1's Auth.vue already
uses). Other browsers keep the animation. The BackgroundArt fallback is
moved from an inline style into CSS so the override can take effect.

Generated-By: PostHog Code
Task-Id: d82d41fa-0db7-477d-bb80-fc512558e076
This commit is contained in:
Georges-Antoine Assi
2026-07-06 22:39:05 -04:00
parent 30274cb31d
commit e0e2e109b1
5 changed files with 47 additions and 10 deletions

View File

@@ -14,23 +14,19 @@ defineProps<{
<template>
<div class="r-v2-bg">
<!-- Fallback art (no cover) comes from the CSS `background-image` on
`.r-v2-bg__layer` so Firefox can swap it for the static variant via
`@-moz-document`; an inline style here would win over that override.
A real cover URL still sets the inline background-image. -->
<div
class="r-v2-bg__layer r-v2-bg__layer--a"
:class="{ 'r-v2-bg__layer--active': activeLayer === 'a' }"
:style="
layerA
? { backgroundImage: `url('${layerA}')` }
: { backgroundImage: `url('/assets/auth_background.svg')` }
"
:style="layerA ? { backgroundImage: `url('${layerA}')` } : {}"
/>
<div
class="r-v2-bg__layer r-v2-bg__layer--b"
:class="{ 'r-v2-bg__layer--active': activeLayer === 'b' }"
:style="
layerB
? { backgroundImage: `url('${layerB}')` }
: { backgroundImage: `url('/assets/auth_background.svg')` }
"
:style="layerB ? { backgroundImage: `url('${layerB}')` } : {}"
/>
</div>
<div class="r-v2-bg__overlay" />

View File

@@ -76,6 +76,15 @@ onMounted(installInputModality);
z-index: 0;
}
/* Firefox: WebRender re-rasterizes the animated SVG every frame, pegging the
GPU. Swap to the static variant in Gecko only (the empty `url-prefix()`
hack matches all Firefox pages and stays enabled by default). */
@-moz-document url-prefix() {
.r-v2-auth__bg {
background-image: url("/assets/auth_background_static.svg");
}
}
.r-v2-auth__stage {
position: relative;
z-index: 1;

View File

@@ -145,6 +145,9 @@ html[data-input="pad"] .r-v2 * {
.r-v2-bg__layer {
position: absolute;
inset: 0;
/* Fallback art when no cover is set (settings, admin, etc.). Kept in CSS
rather than inline so Firefox can swap it for the static variant below. */
background-image: url("/assets/auth_background.svg");
background-size: cover;
background-position: center 20%;
background-repeat: no-repeat;
@@ -154,6 +157,17 @@ html[data-input="pad"] .r-v2 * {
will-change: opacity;
}
/* Firefox: the animated fallback SVG is re-rasterized every frame under the
28px blur (and re-sampled by every backdrop-filter surface), pegging the
WebRender backend. Use the static variant in Gecko only (the empty
`url-prefix()` hack matches all Firefox pages and stays enabled by
default). Cover art is raster, so it's unaffected. */
@-moz-document url-prefix() {
.r-v2-bg__layer {
background-image: url("/assets/auth_background_static.svg");
}
}
.r-v2-bg__layer--a {
opacity: 1;
}

View File

@@ -52,6 +52,15 @@ import DevicePair from "@/v2/views/DevicePair.vue";
z-index: 0;
}
/* Firefox: WebRender re-rasterizes the animated SVG every frame, pegging the
GPU. Swap to the static variant in Gecko only (the empty `url-prefix()`
hack matches all Firefox pages and stays enabled by default). */
@-moz-document url-prefix() {
.r-v2-devpair-shell__bg {
background-image: url("/assets/auth_background_static.svg");
}
}
.r-v2-devpair-shell__stage {
position: relative;
z-index: 1;

View File

@@ -39,6 +39,15 @@ import Pair from "@/v2/views/Pair.vue";
z-index: 0;
}
/* Firefox: WebRender re-rasterizes the animated SVG every frame, pegging the
GPU. Swap to the static variant in Gecko only (the empty `url-prefix()`
hack matches all Firefox pages and stays enabled by default). */
@-moz-document url-prefix() {
.r-v2-pair-shell__bg {
background-image: url("/assets/auth_background_static.svg");
}
}
.r-v2-pair-shell__stage {
position: relative;
z-index: 1;