mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2025-12-30 03:12:29 +00:00
feat(compute-pressure) monitor cpu pressure (#13645)
This commit is contained in:
2
globals.d.ts
vendored
2
globals.d.ts
vendored
@@ -19,6 +19,8 @@ declare global {
|
||||
interfaceConfig?: any;
|
||||
JitsiMeetJS?: any;
|
||||
JitsiMeetElectron?: any;
|
||||
PressureObserver?: any;
|
||||
PressureRecord?: any;
|
||||
// selenium tests handler
|
||||
_sharedVideoPlayer: any;
|
||||
alwaysOnTop: { api: any };
|
||||
|
||||
2
globals.native.d.ts
vendored
2
globals.native.d.ts
vendored
@@ -17,6 +17,8 @@ interface IWindow {
|
||||
innerWidth: number;
|
||||
interfaceConfig: any;
|
||||
location: ILocation;
|
||||
PressureObserver?: any;
|
||||
PressureRecord?: any;
|
||||
self: any;
|
||||
top: any;
|
||||
|
||||
|
||||
@@ -2059,6 +2059,19 @@ class API {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the external application (if API is enabled) when the compute pressure changed.
|
||||
*
|
||||
* @param {Array} records - The new pressure records.
|
||||
* @returns {void}
|
||||
*/
|
||||
notifyComputePressureChanged(records) {
|
||||
this._sendEvent({
|
||||
name: 'compute-pressure-changed',
|
||||
records
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes the allocated resources.
|
||||
*
|
||||
|
||||
1
modules/API/external/external_api.js
vendored
1
modules/API/external/external_api.js
vendored
@@ -106,6 +106,7 @@ const events = {
|
||||
'browser-support': 'browserSupport',
|
||||
'camera-error': 'cameraError',
|
||||
'chat-updated': 'chatUpdated',
|
||||
'compute-pressure-changed': 'computePressureChanged',
|
||||
'content-sharing-participants-changed': 'contentSharingParticipantsChanged',
|
||||
'data-channel-closed': 'dataChannelClosed',
|
||||
'data-channel-opened': 'dataChannelOpened',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import '../analytics/middleware';
|
||||
import '../authentication/middleware';
|
||||
import '../av-moderation/middleware';
|
||||
import '../base/app/middleware';
|
||||
import '../base/conference/middleware';
|
||||
import '../base/config/middleware';
|
||||
import '../base/jwt/middleware';
|
||||
|
||||
54
react/features/base/app/middleware.ts
Normal file
54
react/features/base/app/middleware.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { AnyAction } from 'redux';
|
||||
|
||||
import MiddlewareRegistry from '../../base/redux/MiddlewareRegistry';
|
||||
|
||||
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
|
||||
import logger from './logger';
|
||||
|
||||
|
||||
/**
|
||||
* Experimental feature to monitor CPU pressure.
|
||||
*/
|
||||
let pressureObserver: typeof window.PressureObserver;
|
||||
|
||||
/**
|
||||
* Middleware which intercepts app actions to handle changes to the related state.
|
||||
*
|
||||
* @param {Store} store - The redux store.
|
||||
* @returns {Function}
|
||||
*/
|
||||
MiddlewareRegistry.register(() => (next: Function) => async (action: AnyAction) => {
|
||||
|
||||
switch (action.type) {
|
||||
case APP_WILL_MOUNT: {
|
||||
if ('PressureObserver' in globalThis) {
|
||||
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 }
|
||||
);
|
||||
|
||||
try {
|
||||
pressureObserver
|
||||
.observe('cpu')
|
||||
.catch((e: any) => logger.error('CPU pressure observer failed to start', e));
|
||||
} catch (e: any) {
|
||||
logger.error('CPU pressure observer failed to start', e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case APP_WILL_UNMOUNT: {
|
||||
if (pressureObserver) {
|
||||
pressureObserver.unobserve('cpu');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return next(action);
|
||||
});
|
||||
@@ -339,7 +339,7 @@ module.exports = (_env, argv) => {
|
||||
...config.plugins,
|
||||
...getBundleAnalyzerPlugin(analyzeBundle, 'external_api')
|
||||
],
|
||||
performance: getPerformanceHints(perfHintOptions, 35 * 1024)
|
||||
performance: getPerformanceHints(perfHintOptions, 40 * 1024)
|
||||
}),
|
||||
Object.assign({}, config, {
|
||||
entry: {
|
||||
|
||||
Reference in New Issue
Block a user