Tidy the background effect pipeline after review

- The Vite transform wrapper takes Vite's own types, with no cast.
- The pipeline's options are compared with deepCompare, not as JSON.
- Renames `attached` to `enable` and shortens the pipeline's doc comment.
- Drops a comment that blamed an ended track on the pipeline's queue.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
fkwp
2026-10-08 12:22:34 +02:00
co-authored by Claude Opus 5.5
parent e2b89a64b9
commit ce41fee6ff
3 changed files with 11 additions and 21 deletions
+5 -8
View File
@@ -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<boolean>;
/**
* 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) => {