mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-07 19:22:14 +09:00
chore(desktop): drop Chromium switches that no longer exist (#2660)
This commit is contained in:
@@ -19,14 +19,6 @@ const transformedSource = esbuild.transformSync(source, {
|
||||
target: 'node20',
|
||||
}).code;
|
||||
|
||||
const WGC_DISABLED_FEATURES = [
|
||||
'AllowWgcScreenCapturer',
|
||||
'AllowWgcWindowCapturer',
|
||||
'AllowWgcScreenZeroHz',
|
||||
'AllowWgcWindowZeroHz',
|
||||
'WebRtcWgcRequireBorder',
|
||||
];
|
||||
|
||||
function loadChromiumRuntime(platform = 'win32') {
|
||||
const appendedSwitches = [];
|
||||
const app = {
|
||||
@@ -66,25 +58,20 @@ function loadChromiumRuntime(platform = 'win32') {
|
||||
}
|
||||
|
||||
describe('ChromiumRuntime Windows capture policy', () => {
|
||||
test('adds all known WebRTC WGC capturer features to the Windows disable set', () => {
|
||||
test('leaves the choice of Windows graphics capture to Chromium', () => {
|
||||
const {module} = loadChromiumRuntime('win32');
|
||||
const features = new Set(['ExistingFeature']);
|
||||
const features = new Set(module.BASE_DISABLED_CHROMIUM_FEATURES);
|
||||
|
||||
module.addWindowsWebRtcWgcDisabledFeatures(features);
|
||||
|
||||
for (const feature of WGC_DISABLED_FEATURES) {
|
||||
assert.equal(features.has(feature), true);
|
||||
for (const [name, value] of Object.entries(module)) {
|
||||
if (typeof value === 'function' && name.startsWith('addWindows') && name.endsWith('Features')) {
|
||||
value(features);
|
||||
}
|
||||
}
|
||||
assert.equal(features.has('ExistingFeature'), true);
|
||||
});
|
||||
|
||||
test('does not add WGC feature switches on non-Windows platforms', () => {
|
||||
const {module} = loadChromiumRuntime('linux');
|
||||
const features = new Set(['ExistingFeature']);
|
||||
|
||||
module.addWindowsWebRtcWgcDisabledFeatures(features);
|
||||
|
||||
assert.deepEqual([...features], ['ExistingFeature']);
|
||||
assert.deepEqual(
|
||||
[...features].filter((feature) => feature.includes('Wgc')),
|
||||
[],
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -36,13 +36,6 @@ const MACOS_PRE_SEQUOIA_SCREEN_CAPTURE_DISABLED_FEATURES = [
|
||||
'WarmScreenCaptureSonoma',
|
||||
'UseSCContentSharingPicker',
|
||||
];
|
||||
const WINDOWS_WEBRTC_WGC_DISABLED_FEATURES = [
|
||||
'AllowWgcScreenCapturer',
|
||||
'AllowWgcWindowCapturer',
|
||||
'AllowWgcScreenZeroHz',
|
||||
'AllowWgcWindowZeroHz',
|
||||
'WebRtcWgcRequireBorder',
|
||||
];
|
||||
const WINDOWS_NVIDIA_HEVC_DECODE_WORKAROUND_DEVICE_IDS = new Set([
|
||||
4928, 4929, 4932, 4934, 4935, 4936, 4937, 4939, 4941, 4942, 4943, 4986, 4987, 4992, 4993, 4994, 5008, 5009, 5010,
|
||||
5011, 5016, 5017, 5018, 5019, 5020, 5021, 5040, 5041, 5042, 5043, 5044, 5046, 5049, 5050, 5051, 5052, 5056, 5058,
|
||||
@@ -312,13 +305,6 @@ export function addMacosPreSequoiaScreenCaptureDisabledFeatures(features: Set<st
|
||||
}
|
||||
}
|
||||
|
||||
export function addWindowsWebRtcWgcDisabledFeatures(features: Set<string>): void {
|
||||
if (process.platform !== 'win32') return;
|
||||
for (const feature of WINDOWS_WEBRTC_WGC_DISABLED_FEATURES) {
|
||||
features.add(feature);
|
||||
}
|
||||
}
|
||||
|
||||
export function addLinuxHardwareVideoEncodeFeatures(features: Set<string>): void {
|
||||
if (process.platform !== 'linux') return;
|
||||
features.add('AcceleratedVideoEncoder');
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import assert from 'node:assert/strict';
|
||||
import {readFileSync} from 'node:fs';
|
||||
import {createRequire} from 'node:module';
|
||||
import {describe, test} from 'node:test';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import vm from 'node:vm';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const esbuild = require('esbuild');
|
||||
|
||||
const sourcePath = fileURLToPath(new URL('./PlatformInfo.ts', import.meta.url));
|
||||
const source = readFileSync(sourcePath, 'utf8');
|
||||
const transformedSource = esbuild.transformSync(source, {
|
||||
loader: 'ts',
|
||||
format: 'cjs',
|
||||
platform: 'node',
|
||||
target: 'node20',
|
||||
}).code;
|
||||
|
||||
function loadPlatformInfo(platform = 'win32') {
|
||||
const app = {
|
||||
getVersion: () => '0.0.0-test',
|
||||
commandLine: {
|
||||
getSwitchValue: () => '',
|
||||
hasSwitch: () => true,
|
||||
},
|
||||
};
|
||||
const osModule = {
|
||||
arch: () => 'x64',
|
||||
release: () => '10.0.26100',
|
||||
};
|
||||
|
||||
function requireStub(specifier) {
|
||||
if (specifier === 'node:module') {
|
||||
return {
|
||||
createRequire: () => (moduleSpecifier) => {
|
||||
throw new Error(`Unexpected native module require: ${moduleSpecifier}`);
|
||||
},
|
||||
};
|
||||
}
|
||||
if (specifier === 'node:os') return osModule;
|
||||
if (specifier === 'electron') return {app};
|
||||
if (specifier === '@electron/common/BuildChannel') return {BUILD_CHANNEL: 'stable'};
|
||||
if (specifier === '@electron/common/UserDataPath') return {isPortableMode: () => false};
|
||||
if (specifier === '@electron/main/LinuxSandbox') {
|
||||
return {getFlatpakAppId: () => null, isFlatpakRuntime: () => false};
|
||||
}
|
||||
throw new Error(`Unexpected import: ${specifier}`);
|
||||
}
|
||||
|
||||
const module = {exports: {}};
|
||||
const context = vm.createContext({
|
||||
require: requireStub,
|
||||
module,
|
||||
exports: module.exports,
|
||||
process: {
|
||||
...process,
|
||||
platform,
|
||||
env: {},
|
||||
versions: {...process.versions},
|
||||
getSystemVersion: () => '10.0.26100',
|
||||
},
|
||||
console,
|
||||
});
|
||||
vm.runInContext(transformedSource, context, {filename: sourcePath});
|
||||
return module.exports;
|
||||
}
|
||||
|
||||
describe('PlatformInfo Chromium runtime diagnostics', () => {
|
||||
test('never reports Media Foundation H.264 switches that Chromium no longer has', async () => {
|
||||
const module = loadPlatformInfo('win32');
|
||||
|
||||
const info = await module.getDesktopInfo({nativeProbes: false});
|
||||
|
||||
const switches = [...info.chromiumRuntime.switches];
|
||||
|
||||
assert.deepEqual(
|
||||
switches.filter((name) => name.startsWith('enable-h264-mf')),
|
||||
[],
|
||||
);
|
||||
assert.equal(switches.includes('enable-libopenh264'), true);
|
||||
});
|
||||
});
|
||||
@@ -53,8 +53,6 @@ const CHROMIUM_RUNTIME_SWITCHES = [
|
||||
'disable-renderer-backgrounding',
|
||||
'disable_nv12_dxgi_video',
|
||||
'enable-libopenh264',
|
||||
'enable-h264-mf',
|
||||
'enable-h264-mf-zero-copy',
|
||||
'force_high_performance_gpu',
|
||||
'force_low_power_gpu',
|
||||
'openh264-library-path',
|
||||
|
||||
@@ -201,7 +201,7 @@ describe('StreamingPriority GPU scheduling priority', () => {
|
||||
status: 'succeeded',
|
||||
priorityClass: 'high',
|
||||
targets: [
|
||||
{processId: 1000, reasons: ['native-main-encoder-capture']},
|
||||
{processId: 1000, reasons: ['browser-main']},
|
||||
{processId: 2001, reasons: ['renderer']},
|
||||
{processId: 3001, reasons: ['chromium-gpu']},
|
||||
{processId: 3002, reasons: ['chromium-video-encode']},
|
||||
@@ -352,7 +352,7 @@ describe('StreamingPriority GPU scheduling priority', () => {
|
||||
status: 'native-module-unavailable',
|
||||
priorityClass: 'high',
|
||||
targets: [
|
||||
{processId: 1000, reasons: ['native-main-encoder-capture']},
|
||||
{processId: 1000, reasons: ['browser-main']},
|
||||
{processId: 2001, reasons: ['renderer']},
|
||||
{processId: 3001, reasons: ['chromium-gpu']},
|
||||
],
|
||||
|
||||
@@ -16,7 +16,7 @@ const requireModule = createRequire(import.meta.url);
|
||||
|
||||
type WindowsGpuSchedulingPriority = 'high' | 'realtime';
|
||||
type WindowsGpuPriorityTargetReason =
|
||||
| 'native-main-encoder-capture'
|
||||
| 'browser-main'
|
||||
| 'renderer'
|
||||
| 'tracked-renderer'
|
||||
| 'chromium-gpu'
|
||||
@@ -308,7 +308,7 @@ function getChromiumProcessTargetReasons(metric: Electron.ProcessMetric): Array<
|
||||
|
||||
function collectGpuSchedulingPriorityTargets(webContents?: Electron.WebContents): Array<GpuPriorityTarget> {
|
||||
const targets = new Map<number, Set<WindowsGpuPriorityTargetReason>>();
|
||||
addGpuPriorityTarget(targets, process.pid, 'native-main-encoder-capture');
|
||||
addGpuPriorityTarget(targets, process.pid, 'browser-main');
|
||||
const rendererProcessId = getRendererProcessId(webContents);
|
||||
addGpuPriorityTarget(targets, rendererProcessId, 'renderer');
|
||||
for (const trackedWebContents of streamingPriorityWebContents) {
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
addLinuxScreenCapturePipeWireFeature,
|
||||
addMacosPreSequoiaScreenCaptureDisabledFeatures,
|
||||
addWindowsHardwareVideoEncodeFeatures,
|
||||
addWindowsWebRtcWgcDisabledFeatures,
|
||||
appendConfiguredChromiumSwitches,
|
||||
appendDisabledChromiumFeatures,
|
||||
appendEnabledBlinkFeature,
|
||||
@@ -268,7 +267,6 @@ if (launchConfigurationError) {
|
||||
if (process.platform === 'darwin') {
|
||||
addMacosPreSequoiaScreenCaptureDisabledFeatures(disabledChromiumFeatures);
|
||||
}
|
||||
addWindowsWebRtcWgcDisabledFeatures(disabledChromiumFeatures);
|
||||
appendDisabledChromiumFeatures(disabledChromiumFeatures);
|
||||
if (enabledChromiumFeatures.size > 0) {
|
||||
appendEnabledChromiumFeatures(enabledChromiumFeatures);
|
||||
@@ -279,8 +277,6 @@ if (launchConfigurationError) {
|
||||
}
|
||||
appendLinuxOzonePlatformHint();
|
||||
if (process.platform === 'win32') {
|
||||
app.commandLine.appendSwitch('enable-h264-mf');
|
||||
app.commandLine.appendSwitch('enable-h264-mf-zero-copy');
|
||||
app.setToastActivatorCLSID(WINDOWS_TOAST_ACTIVATOR_CLSID);
|
||||
app.setAppUserModelId(WINDOWS_APP_USER_MODEL_ID);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user