mirror of
https://github.com/vector-im/element-call.git
synced 2026-10-16 23:45:50 +00:00
Offer background effects on any platform whose browser can run them
- The desktop rule from #4059 goes: now that the menu says where effects run slowly, using them there is the user's choice. A phone on the fast route held 99% of its frame rate and was refused; a desktop on the slow one held 73% and was allowed. - Asks @livekit/track-processors directly; the wrapper module goes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -254,12 +254,12 @@ describe("createCallFooterViewModel", () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
it("offers nothing on a phone, where the pipeline would refuse them", () => {
|
it("offers them on a phone whose browser can run them", () => {
|
||||||
sdkSupportMock.mockReturnValue(true);
|
sdkSupportMock.mockReturnValue(true);
|
||||||
expect(lobbyOn("ios").selectBackgroundEffect$.value).toBeUndefined();
|
expect(lobbyOn("ios").selectBackgroundEffect$.value).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("offers them where the pipeline will honour them", () => {
|
it("offers them on a desktop whose browser can run them", () => {
|
||||||
sdkSupportMock.mockReturnValue(true);
|
sdkSupportMock.mockReturnValue(true);
|
||||||
expect(lobbyOn("desktop").selectBackgroundEffect$.value).toBeDefined();
|
expect(lobbyOn("desktop").selectBackgroundEffect$.value).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ import {
|
|||||||
switchMap,
|
switchMap,
|
||||||
} from "rxjs";
|
} from "rxjs";
|
||||||
import { supportsAudioOutputSelection } from "livekit-client";
|
import { supportsAudioOutputSelection } from "livekit-client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
supportsBackgroundProcessors,
|
supportsBackgroundProcessors,
|
||||||
usesFallbackProcessing,
|
supportsModernBackgroundProcessors,
|
||||||
} from "../livekit/backgroundProcessing";
|
} from "@livekit/track-processors";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
parseEffect,
|
parseEffect,
|
||||||
serializeEffect,
|
serializeEffect,
|
||||||
@@ -112,7 +112,7 @@ function buildDeviceBehaviors(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const supported = supportsBackgroundProcessors();
|
const supported = supportsBackgroundProcessors();
|
||||||
const slow = usesFallbackProcessing();
|
const slow = !supportsModernBackgroundProcessors();
|
||||||
const offered$ = disableSwitcher$.pipe(
|
const offered$ = disableSwitcher$.pipe(
|
||||||
map((switcherDisabled) => !switcherDisabled && supported),
|
map((switcherDisabled) => !switcherDisabled && supported),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -199,14 +199,14 @@ describe("BackgroundEffectsProvider", () => {
|
|||||||
expect(track.stopProcessor).not.toHaveBeenCalled();
|
expect(track.stopProcessor).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not run on a phone, even where its browser could", async () => {
|
it("runs on a phone whose browser can run it", async () => {
|
||||||
platformMock.platform = "ios";
|
platformMock.platform = "ios";
|
||||||
const track = cameraTrack();
|
const track = cameraTrack();
|
||||||
render(surfaces(track));
|
render(surfaces(track));
|
||||||
await blur(true);
|
await blur(true);
|
||||||
|
|
||||||
expect(latest().supported).toBe(false);
|
expect(latest().supported).toBe(true);
|
||||||
expect(track.setProcessor).not.toHaveBeenCalled();
|
expect(track.setProcessor).toHaveBeenCalledWith(latest().processor);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("preview and call share one pipeline", async () => {
|
it("preview and call share one pipeline", async () => {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ Please see LICENSE in the repository root for full details.
|
|||||||
import {
|
import {
|
||||||
type ProcessorWrapper,
|
type ProcessorWrapper,
|
||||||
type BackgroundOptions,
|
type BackgroundOptions,
|
||||||
|
supportsBackgroundProcessors,
|
||||||
} from "@livekit/track-processors";
|
} from "@livekit/track-processors";
|
||||||
import { createContext, type FC, type JSX, use, useEffect } from "react";
|
import { createContext, type FC, type JSX, use, useEffect } from "react";
|
||||||
import { type LocalVideoTrack } from "livekit-client";
|
import { type LocalVideoTrack } from "livekit-client";
|
||||||
@@ -18,7 +19,6 @@ import { combineLatest } from "rxjs";
|
|||||||
import { backgroundEffect as backgroundEffectSetting } from "../settings/settings";
|
import { backgroundEffect as backgroundEffectSetting } from "../settings/settings";
|
||||||
import { BackgroundEffectTransformer } from "./BackgroundEffectTransformer";
|
import { BackgroundEffectTransformer } from "./BackgroundEffectTransformer";
|
||||||
import { OneStepPipeline } from "./OneStepPipeline";
|
import { OneStepPipeline } from "./OneStepPipeline";
|
||||||
import { supportsBackgroundProcessors } from "./backgroundProcessing";
|
|
||||||
import { type Behavior } from "../state/Behavior";
|
import { type Behavior } from "../state/Behavior";
|
||||||
import { type ObservableScope } from "../state/ObservableScope";
|
import { type ObservableScope } from "../state/ObservableScope";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2026 Element Creations Ltd.
|
|
||||||
|
|
||||||
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
||||||
Please see LICENSE in the repository root for full details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import {
|
|
||||||
supportsBackgroundProcessors as supportsBackgroundProcessorsLivekitSdk,
|
|
||||||
supportsModernBackgroundProcessors,
|
|
||||||
} from "@livekit/track-processors";
|
|
||||||
|
|
||||||
import { platform } from "../Platform";
|
|
||||||
|
|
||||||
/** One answer for the controls and the pipeline, so neither offers what the other refuses. */
|
|
||||||
export function supportsBackgroundProcessors(): boolean {
|
|
||||||
return supportsBackgroundProcessorsLivekitSdk() && platform === "desktop";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether effects, where they run at all, draw every frame through a canvas:
|
|
||||||
* the slower route, which costs frame rate and stalls the page while the
|
|
||||||
* first one is built.
|
|
||||||
*/
|
|
||||||
export function usesFallbackProcessing(): boolean {
|
|
||||||
return !supportsModernBackgroundProcessors();
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user