diff --git a/scripts/save-tracks.js b/scripts/save-tracks.js index 251337c..dd0f694 100644 --- a/scripts/save-tracks.js +++ b/scripts/save-tracks.js @@ -16,7 +16,7 @@ function createWorker(fn) { return new Worker(url) } -const saveFileWorker = createWorker(() => { +const saveFileWorkerFn = () => { const log = (...args) => { console.log.apply(null, ['[webrtcperf-savefileworker]', ...args]) } @@ -155,17 +155,24 @@ const saveFileWorker = createWorker(() => { readable.pipeTo(writableStream) } } -}) +} +let saveFileWorker = null const savingTracks = { audio: new Set(), video: new Set(), } -saveFileWorker.onmessage = event => { - const { name, error, kind, id } = event.data - log(`saveFileWorker name=${name} kind=${kind} id=${id} error=${error}`) - savingTracks[kind].delete(id) +const getSaveFileWorker = () => { + if (!saveFileWorker) { + saveFileWorker = createWorker(saveFileWorkerFn) + saveFileWorker.onmessage = event => { + const { name, error, kind, id } = event.data + log(`saveFileWorker name=${name} kind=${kind} id=${id} error=${error}`) + savingTracks[kind].delete(id) + } + } + return saveFileWorker } window.saveMediaTrack = async ( @@ -198,7 +205,7 @@ window.saveMediaTrack = async ( const { readable } = new window.MediaStreamTrackProcessor({ track }) log(`saveMediaTrack ${filename}`) - saveFileWorker.postMessage( + getSaveFileWorker().postMessage( { id, url, diff --git a/src/config.ts b/src/config.ts index 73d38d0..941bbd8 100644 --- a/src/config.ts +++ b/src/config.ts @@ -465,9 +465,10 @@ use the host X server instance.`, arg: 'enable-gpu', }, enableBrowserLogging: { - doc: `It enables the Chromium browser logging to standard output.`, - format: 'Boolean', - default: false, + doc: `It enables the Chromium browser logging, e.g. "--v=0" (see https://www.chromium.org/for-testers/enable-logging/).`, + format: String, + nullable: true, + default: '', env: 'ENABLE_BROWSER_LOGGING', arg: 'enable-browser-logging', }, diff --git a/src/session.ts b/src/session.ts index 28c4476..d152499 100644 --- a/src/session.ts +++ b/src/session.ts @@ -119,7 +119,7 @@ export type SessionParams = { videoHeight: number videoFramerate: number enableGpu: string - enableBrowserLogging: boolean + enableBrowserLogging: string startTimestamp: number sessions: number tabsPerSession: number @@ -187,7 +187,7 @@ export class Session extends EventEmitter { private readonly videoHeight: number private readonly videoFramerate: number private readonly enableGpu: string - private readonly enableBrowserLogging: boolean + private readonly enableBrowserLogging: string private readonly startTimestamp: number private readonly sessions: number private readonly tabsPerSession: number @@ -585,7 +585,7 @@ export class Session extends EventEmitter { } if (this.enableBrowserLogging) { - args = args.concat(['--enable-logging=stderr', '--vmodule=*/webrtc/*=1']) + args = args.concat(['--enable-logging=stderr', this.enableBrowserLogging]) } return args @@ -686,7 +686,7 @@ exec sg ${group} -c /tmp/webrtcperf-launcher-${mark}-browser`, executablePath, handleSIGINT: false, env, - dumpio: this.enableBrowserLogging, + dumpio: !!this.enableBrowserLogging, // devtools: true, ignoreHTTPSErrors: true, defaultViewport: {