diff --git a/src/livekit/TrackProcessorContext.tsx b/src/livekit/TrackProcessorContext.tsx index 473f01dee..ab78179fe 100644 --- a/src/livekit/TrackProcessorContext.tsx +++ b/src/livekit/TrackProcessorContext.tsx @@ -76,8 +76,6 @@ export function applyProcessor( } const track = videoTrack.mediaStreamTrack; videoTrack.setProcessor(processor).catch((e) => { - // The pipeline builds one track at a time, so a track can end while its - // build waits a turn. The camera's next track attaches it again. if (track.readyState === "ended") logger.debug("Video processor not attached: the track ended first"); else logger.warn("Failed to attach video processor", e); diff --git a/src/state/BackgroundEffects.ts b/src/state/BackgroundEffects.ts index 5c50acc7d..3252d2c69 100644 --- a/src/state/BackgroundEffects.ts +++ b/src/state/BackgroundEffects.ts @@ -11,6 +11,7 @@ import { type SwitchBackgroundProcessorOptions, } from "@livekit/track-processors"; import { logger } from "matrix-js-sdk/lib/logger"; +import { deepCompare } from "matrix-js-sdk/lib/utils"; import { type Behavior } from "./Behavior"; import { type ObservableScope } from "./ObservableScope"; @@ -23,11 +24,7 @@ export interface BackgroundEffectsOptions { supported: boolean; /** Whether blur is chosen. */ blur$: Behavior; - /** - * Shared by the pre-join preview and the call. Building or destroying it is - * what primes it, and a primed pipeline lets its next frame through - * untouched, so it is switched rather than rebuilt. - */ + /** The background processor pipeline to be switched between effects. */ pipeline: BackgroundProcessorWrapper; } @@ -45,9 +42,9 @@ export class BackgroundEffects { (previous, wanted) => { // Attached the first time an effect is wanted and never detached // after, so someone who never turns one on pays for none of it. - const attached = + const enable = previous.processor !== undefined || (supported && wanted); - return { supported, processor: attached ? pipeline : undefined }; + return { supported, processor: enable ? pipeline : undefined }; }, { supported, processor: undefined }, ), @@ -61,7 +58,7 @@ export class BackgroundEffects { map(([, blur]): SwitchBackgroundProcessorOptions => blur ? { mode: "background-blur", blurRadius } : { mode: "disabled" }, ), - distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)), + distinctUntilChanged(deepCompare), scope.bind(), ) .subscribe((options) => { diff --git a/vite.config.ts b/vite.config.ts index 2abba3dca..f3098b894 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -7,6 +7,7 @@ Please see LICENSE in the repository root for full details. import { loadEnv, + type Plugin, type PluginOption, searchForWorkspaceRoot, type ConfigEnv, @@ -196,19 +197,13 @@ function exceptMediaPipeWasm(plugins: PluginOption): PluginOption { ) return plugin; const transform = plugin.transform; - return { + const wrapped: Plugin = { ...plugin, - transform(this: unknown, code: string, id: string, options: unknown) { + transform(code, id, options) { if (isLoader(id)) return null; - return ( - transform as ( - this: unknown, - c: string, - i: string, - o: unknown, - ) => unknown - ).call(this, code, id, options); + return transform.call(this, code, id, options); }, - } as PluginOption; + }; + return wrapped; }); }