From f3626a2dc6348a866251f560ff456a1edfc49344 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Thu, 6 Aug 2026 13:00:21 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(frontend)=20serve=20MediaPipe=20as?= =?UTF-8?q?sets=20under=20a=20versioned=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MediaPipe assets were served under /assets, where the cache behavior differs between wasm and js files. As a result, clients could end up with a fresh js loader paired with a stale wasm binary (or vice versa), leaving MediaPipe out of sync. Copy the assets under a versioned route so the URL changes whenever the dependency version bumps. Clients then reload both the js and the wasm together, keeping them in sync. --- CHANGELOG.md | 4 ++++ .../rooms/livekit/components/blur/index.ts | 2 +- src/frontend/src/vite-env.d.ts | 4 ++++ src/frontend/vite.config.ts | 16 +++++++++++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48be014f..a78ea7ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to ## [Unreleased] +### Fixed + +- 🐛(frontend) serve MediaPipe assets under a versioned path + ## [1.25.1] - 2026-08-06 ### Fixed diff --git a/src/frontend/src/features/rooms/livekit/components/blur/index.ts b/src/frontend/src/features/rooms/livekit/components/blur/index.ts index e6399f83..6d025915 100644 --- a/src/frontend/src/features/rooms/livekit/components/blur/index.ts +++ b/src/frontend/src/features/rooms/livekit/components/blur/index.ts @@ -10,7 +10,7 @@ export const SELFIE_SEGMENTER_MODEL_PATH = export const FACE_LANDMARKS_MODEL_PATH = '/assets/mediapipe/models/face_landmarker.task' -export const MEDIAPIPE_PATH_WASM = '/assets/mediapipe/wasm' +export const MEDIAPIPE_PATH_WASM = `/assets/mediapipe/wasm/${__MEDIAPIPE_VERSION__}` export enum ProcessorType { BLUR = 'blur', diff --git a/src/frontend/src/vite-env.d.ts b/src/frontend/src/vite-env.d.ts index c7205443..0fe1fb43 100644 --- a/src/frontend/src/vite-env.d.ts +++ b/src/frontend/src/vite-env.d.ts @@ -1,4 +1,8 @@ /// + +// Version of @mediapipe/tasks-vision, injected at build time (vite.config.ts). +declare const __MEDIAPIPE_VERSION__: string + interface ImportMetaEnv { readonly VITE_API_BASE_URL: string readonly VITE_APP_TITLE: string diff --git a/src/frontend/vite.config.ts b/src/frontend/vite.config.ts index 241dc98c..f29fd306 100644 --- a/src/frontend/vite.config.ts +++ b/src/frontend/vite.config.ts @@ -1,13 +1,27 @@ +import { readFileSync } from 'node:fs' import { defineConfig, loadEnv } from 'vite' import react from '@vitejs/plugin-react' import { visualizer } from 'rollup-plugin-visualizer' import svgr from 'vite-plugin-svgr' import { viteStaticCopy } from 'vite-plugin-static-copy' +const mediapipeVersion: string = JSON.parse( + readFileSync( + new URL( + './node_modules/@mediapipe/tasks-vision/package.json', + import.meta.url + ), + 'utf-8' + ) +).version + // https://vitejs.dev/config/ export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd()) return { + define: { + __MEDIAPIPE_VERSION__: JSON.stringify(mediapipeVersion), + }, plugins: [ react(), svgr({ @@ -23,7 +37,7 @@ export default defineConfig(({ mode }) => { targets: [ { src: 'node_modules/@mediapipe/tasks-vision/wasm/*', - dest: 'assets/mediapipe/wasm', + dest: `assets/mediapipe/wasm/${mediapipeVersion}`, rename: { stripBase: 4 }, }, {