From f28bd67ff493df76be03f4a82bb41be520657ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Fri, 27 Jun 2025 14:03:00 +0200 Subject: [PATCH] fix(PressureObserver) adapt to API changes Also set a sampling intervakl of 30s to avoid too chatty logs. --- react/features/base/app/middleware.web.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/react/features/base/app/middleware.web.ts b/react/features/base/app/middleware.web.ts index a91492b467..8475d206bd 100644 --- a/react/features/base/app/middleware.web.ts +++ b/react/features/base/app/middleware.web.ts @@ -24,20 +24,17 @@ MiddlewareRegistry.register(() => (next: Function) => (action: AnyAction) => { case APP_WILL_MOUNT: { // Disable it inside an iframe until Google fixes the origin trial for 3rd party sources: // https://bugs.chromium.org/p/chromium/issues/detail?id=1504167 - if (!isEmbedded() && 'PressureObserver' in globalThis) { + if (!isEmbedded() && 'PressureObserver' in window) { pressureObserver = new window.PressureObserver( (records: typeof window.PressureRecord) => { logger.info('Compute pressure state changed:', JSON.stringify(records)); - if (typeof APP !== 'undefined') { - APP.API.notifyComputePressureChanged(records); - } - }, - { sampleRate: 1 } + APP.API.notifyComputePressureChanged(records); + } ); try { pressureObserver - .observe('cpu') + .observe('cpu', { sampleInterval: 30_000 }) .catch((e: any) => logger.error('CPU pressure observer failed to start', e)); } catch (e: any) { logger.error('CPU pressure observer failed to start', e);