Browse Source

feat(build,virtual-background) don't use an external bundle for the effect

The majority of the code is in the WASM file and models, this is just a few KB.
It's so little, in fact, that the performance hint for the main bundle didn't
have to be adjusted.
j8
Saúl Ibarra Corretgé 4 years ago
parent
commit
22b6d32174

+ 0
- 2
Makefile View File

51
 		$(OUTPUT_DIR)/analytics-ga.js \
51
 		$(OUTPUT_DIR)/analytics-ga.js \
52
 		$(BUILD_DIR)/analytics-ga.min.js \
52
 		$(BUILD_DIR)/analytics-ga.min.js \
53
 		$(BUILD_DIR)/analytics-ga.min.map \
53
 		$(BUILD_DIR)/analytics-ga.min.map \
54
-		$(BUILD_DIR)/virtual-background-effect.min.js \
55
-		$(BUILD_DIR)/virtual-background-effect.min.map \
56
 		$(BUILD_DIR)/rnnoise-processor.min.js \
54
 		$(BUILD_DIR)/rnnoise-processor.min.js \
57
 		$(BUILD_DIR)/rnnoise-processor.min.map \
55
 		$(BUILD_DIR)/rnnoise-processor.min.map \
58
 		$(BUILD_DIR)/close3.min.js \
56
 		$(BUILD_DIR)/close3.min.js \

+ 4
- 3
react/features/base/tracks/loadEffects.web.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
 import { createScreenshotCaptureEffect } from '../../stream-effects/screenshot-capture';
3
 import { createScreenshotCaptureEffect } from '../../stream-effects/screenshot-capture';
4
-import { getBackgroundEffect } from '../../virtual-background';
4
+import { createVirtualBackgroundEffect } from '../../stream-effects/virtual-background';
5
 
5
 
6
 import logger from './logger';
6
 import logger from './logger';
7
 
7
 
13
  */
13
  */
14
 export default function loadEffects(store: Object): Promise<any> {
14
 export default function loadEffects(store: Object): Promise<any> {
15
     const state = store.getState();
15
     const state = store.getState();
16
+    const virtualBackground = state['features/virtual-background'];
16
 
17
 
17
-    const backgroundPromise = state['features/virtual-background'].backgroundEffectEnabled
18
-        ? getBackgroundEffect()
18
+    const backgroundPromise = virtualBackground.backgroundEffectEnabled
19
+        ? createVirtualBackgroundEffect(virtualBackground)
19
             .catch(error => {
20
             .catch(error => {
20
                 logger.error('Failed to obtain the background effect instance with error: ', error);
21
                 logger.error('Failed to obtain the background effect instance with error: ', error);
21
 
22
 

+ 3
- 3
react/features/virtual-background/actions.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
-import { getLocalVideoTrack } from '../../features/base/tracks';
3
+import { getLocalVideoTrack } from '../base/tracks';
4
+import { createVirtualBackgroundEffect } from '../stream-effects/virtual-background';
4
 
5
 
5
 import { BACKGROUND_ENABLED, SET_VIRTUAL_BACKGROUND } from './actionTypes';
6
 import { BACKGROUND_ENABLED, SET_VIRTUAL_BACKGROUND } from './actionTypes';
6
-import { getBackgroundEffect } from './functions';
7
 import logger from './logger';
7
 import logger from './logger';
8
 
8
 
9
 /**
9
 /**
21
 
21
 
22
         try {
22
         try {
23
             if (enabled) {
23
             if (enabled) {
24
-                await jitsiTrack.setEffect(await getBackgroundEffect(virtualBackground));
24
+                await jitsiTrack.setEffect(await createVirtualBackgroundEffect(virtualBackground));
25
                 dispatch(backgroundEnabled(true));
25
                 dispatch(backgroundEnabled(true));
26
             } else {
26
             } else {
27
                 await jitsiTrack.setEffect(undefined);
27
                 await jitsiTrack.setEffect(undefined);

+ 0
- 19
react/features/virtual-background/functions.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
-import { getJitsiMeetGlobalNS, loadScript } from '../base/util';
4
 
3
 
5
 let filterSupport;
4
 let filterSupport;
6
 
5
 
7
-/**
8
- * Returns promise that resolves with the blur effect instance.
9
- *
10
- * @param {Object} virtualBackground - The virtual object that contains the background image source and
11
- * the isVirtualBackground flag that indicates if virtual image is activated .
12
- * @returns {Promise<JitsiStreamBackgroundEffect>} - Resolves with the background effect instance.
13
- */
14
-export function getBackgroundEffect(virtualBackground: Object) {
15
-    const ns = getJitsiMeetGlobalNS();
16
-
17
-    if (ns.effects && ns.effects.createVirtualBackgroundEffect) {
18
-        return ns.effects.createVirtualBackgroundEffect(virtualBackground);
19
-    }
20
-
21
-    return loadScript('libs/virtual-background-effect.min.js').then(() =>
22
-        ns.effects.createVirtualBackgroundEffect(virtualBackground));
23
-}
24
-
25
 /**
6
 /**
26
  * Checks context filter support.
7
  * Checks context filter support.
27
  *
8
  *

+ 0
- 13
webpack.config.js View File

247
     // and sourceMapFilename parameters which target libs without .min in dev
247
     // and sourceMapFilename parameters which target libs without .min in dev
248
     // mode. Thus we change these modules to have the same filename in both
248
     // mode. Thus we change these modules to have the same filename in both
249
     // prod and dev mode.
249
     // prod and dev mode.
250
-    Object.assign({}, config, {
251
-        entry: {
252
-            'virtual-background-effect': './react/features/stream-effects/virtual-background/index.js'
253
-        },
254
-        output: Object.assign({}, config.output, {
255
-            library: [ 'JitsiMeetJS', 'app', 'effects' ],
256
-            libraryTarget: 'window',
257
-            filename: '[name].min.js',
258
-            sourceMapFilename: '[name].min.map'
259
-        }),
260
-        performance: getPerformanceHints(1 * 1024 * 1024)
261
-    }),
262
-
263
     Object.assign({}, config, {
250
     Object.assign({}, config, {
264
         entry: {
251
         entry: {
265
             'rnnoise-processor': './react/features/stream-effects/rnnoise/index.js'
252
             'rnnoise-processor': './react/features/stream-effects/rnnoise/index.js'

Loading…
Cancel
Save