| 
				
			 | 
			
			
				
				@@ -1,11 +1,11 @@ 
			 | 
		
		
	
		
			
			| 
				1
			 | 
			
				1
			 | 
			
			
				
				 // @flow 
			 | 
		
		
	
		
			
			| 
				2
			 | 
			
				2
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				3
			 | 
			
				
			 | 
			
			
				
				-import * as wasmCheck from 'wasm-check'; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				3
			 | 
			
			
				
				+import { showWarningNotification } from '../../notifications/actions'; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				4
			 | 
			
			
				
				+import logger from '../../virtual-background/logger'; 
			 | 
		
		
	
		
			
			| 
				4
			 | 
			
				5
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				5
			 | 
			
				6
			 | 
			
			
				
				 import JitsiStreamBackgroundEffect from './JitsiStreamBackgroundEffect'; 
			 | 
		
		
	
		
			
			| 
				6
			 | 
			
				7
			 | 
			
			
				
				 import createTFLiteModule from './vendor/tflite/tflite'; 
			 | 
		
		
	
		
			
			| 
				7
			 | 
			
				8
			 | 
			
			
				
				 import createTFLiteSIMDModule from './vendor/tflite/tflite-simd'; 
			 | 
		
		
	
		
			
			| 
				8
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				9
			 | 
			
				9
			 | 
			
			
				
				 const models = { 
			 | 
		
		
	
		
			
			| 
				10
			 | 
			
				10
			 | 
			
			
				
				     model96: 'libs/segm_lite_v681.tflite', 
			 | 
		
		
	
		
			
			| 
				11
			 | 
			
				11
			 | 
			
			
				
				     model144: 'libs/segm_full_v679.tflite' 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -28,18 +28,36 @@ const segmentationDimensions = { 
			 | 
		
		
	
		
			
			| 
				28
			 | 
			
				28
			 | 
			
			
				
				  * 
			 | 
		
		
	
		
			
			| 
				29
			 | 
			
				29
			 | 
			
			
				
				  * @param {Object} virtualBackground - The virtual object that contains the background image source and 
			 | 
		
		
	
		
			
			| 
				30
			 | 
			
				30
			 | 
			
			
				
				  * the isVirtualBackground flag that indicates if virtual image is activated. 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				31
			 | 
			
			
				
				+ * @param {Function} dispatch - The Redux dispatch function. 
			 | 
		
		
	
		
			
			| 
				31
			 | 
			
				32
			 | 
			
			
				
				  * @returns {Promise<JitsiStreamBackgroundEffect>} 
			 | 
		
		
	
		
			
			| 
				32
			 | 
			
				33
			 | 
			
			
				
				  */ 
			 | 
		
		
	
		
			
			| 
				33
			 | 
			
				
			 | 
			
			
				
				-export async function createVirtualBackgroundEffect(virtualBackground: Object) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				34
			 | 
			
			
				
				+export async function createVirtualBackgroundEffect(virtualBackground: Object, dispatch: Function) { 
			 | 
		
		
	
		
			
			| 
				34
			 | 
			
				35
			 | 
			
			
				
				     if (!MediaStreamTrack.prototype.getSettings && !MediaStreamTrack.prototype.getConstraints) { 
			 | 
		
		
	
		
			
			| 
				35
			 | 
			
				36
			 | 
			
			
				
				         throw new Error('JitsiStreamBackgroundEffect not supported!'); 
			 | 
		
		
	
		
			
			| 
				36
			 | 
			
				37
			 | 
			
			
				
				     } 
			 | 
		
		
	
		
			
			| 
				37
			 | 
			
				38
			 | 
			
			
				
				     let tflite; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				39
			 | 
			
			
				
				+    let wasmCheck; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				40
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				41
			 | 
			
			
				
				+    // Checks if WebAssembly feature is supported or enabled by/in the browser. 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				42
			 | 
			
			
				
				+    // Conditional import of wasm-check package is done to prevent 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				43
			 | 
			
			
				
				+    // the browser from crashing when the user opens the app. 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				44
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				45
			 | 
			
			
				
				+    try { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				46
			 | 
			
			
				
				+        wasmCheck = require('wasm-check'); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				47
			 | 
			
			
				
				+        if (wasmCheck?.feature?.simd) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				48
			 | 
			
			
				
				+            tflite = await createTFLiteSIMDModule(); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				49
			 | 
			
			
				
				+        } else { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				50
			 | 
			
			
				
				+            tflite = await createTFLiteModule(); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				51
			 | 
			
			
				
				+        } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				52
			 | 
			
			
				
				+    } catch (err) { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				53
			 | 
			
			
				
				+        logger.error('Looks like WebAssembly is disabled or not supported on this browser'); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				54
			 | 
			
			
				
				+        dispatch(showWarningNotification({ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				55
			 | 
			
			
				
				+            titleKey: 'virtualBackground.webAssemblyWarning', 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				56
			 | 
			
			
				
				+            description: 'WebAssembly disabled or not supported by this browser' 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				57
			 | 
			
			
				
				+        })); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				58
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				
				+        return; 
			 | 
		
		
	
		
			
			| 
				38
			 | 
			
				60
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				39
			 | 
			
				
			 | 
			
			
				
				-    if (wasmCheck.feature.simd) { 
			 | 
		
		
	
		
			
			| 
				40
			 | 
			
				
			 | 
			
			
				
				-        tflite = await createTFLiteSIMDModule(); 
			 | 
		
		
	
		
			
			| 
				41
			 | 
			
				
			 | 
			
			
				
				-    } else { 
			 | 
		
		
	
		
			
			| 
				42
			 | 
			
				
			 | 
			
			
				
				-        tflite = await createTFLiteModule(); 
			 | 
		
		
	
		
			
			| 
				43
			 | 
			
				61
			 | 
			
			
				
				     } 
			 | 
		
		
	
		
			
			| 
				44
			 | 
			
				62
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				45
			 | 
			
				63
			 | 
			
			
				
				     const modelBufferOffset = tflite._getModelBufferMemoryOffset(); 
			 |