mirror of
https://github.com/element-hq/element-call.git
synced 2026-10-13 02:37:17 +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);
|
||||
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);
|
||||
expect(lobbyOn("desktop").selectBackgroundEffect$.value).toBeDefined();
|
||||
});
|
||||
|
||||
@@ -13,11 +13,11 @@ import {
|
||||
switchMap,
|
||||
} from "rxjs";
|
||||
import { supportsAudioOutputSelection } from "livekit-client";
|
||||
|
||||
import {
|
||||
supportsBackgroundProcessors,
|
||||
usesFallbackProcessing,
|
||||
} from "../livekit/backgroundProcessing";
|
||||
supportsModernBackgroundProcessors,
|
||||
} from "@livekit/track-processors";
|
||||
|
||||
import {
|
||||
parseEffect,
|
||||
serializeEffect,
|
||||
@@ -112,7 +112,7 @@ function buildDeviceBehaviors(
|
||||
);
|
||||
|
||||
const supported = supportsBackgroundProcessors();
|
||||
const slow = usesFallbackProcessing();
|
||||
const slow = !supportsModernBackgroundProcessors();
|
||||
const offered$ = disableSwitcher$.pipe(
|
||||
map((switcherDisabled) => !switcherDisabled && supported),
|
||||
);
|
||||
|
||||
@@ -195,14 +195,14 @@ describe("BackgroundEffectsProvider", () => {
|
||||
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";
|
||||
const track = cameraTrack();
|
||||
render(surfaces(track));
|
||||
await blur(true);
|
||||
|
||||
expect(latest().supported).toBe(false);
|
||||
expect(track.setProcessor).not.toHaveBeenCalled();
|
||||
expect(latest().supported).toBe(true);
|
||||
expect(track.setProcessor).toHaveBeenCalledWith(latest().processor);
|
||||
});
|
||||
|
||||
it("preview and call share one pipeline", async () => {
|
||||
|
||||
@@ -9,6 +9,7 @@ Please see LICENSE in the repository root for full details.
|
||||
import {
|
||||
type ProcessorWrapper,
|
||||
type BackgroundOptions,
|
||||
supportsBackgroundProcessors,
|
||||
} from "@livekit/track-processors";
|
||||
import {
|
||||
createContext,
|
||||
@@ -25,7 +26,6 @@ import { combineLatest } from "rxjs";
|
||||
import { backgroundEffect as backgroundEffectSetting } from "../settings/settings";
|
||||
import { BackgroundEffectTransformer } from "./BackgroundEffectTransformer";
|
||||
import { OneStepPipeline } from "./OneStepPipeline";
|
||||
import { supportsBackgroundProcessors } from "./backgroundProcessing";
|
||||
import { type Behavior } from "../state/Behavior";
|
||||
import { ObservableScope } from "../state/ObservableScope";
|
||||
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