浏览代码

fix(virtual-background) fix track leak in preview

j8
Tudor D. Pop 4 年前
父节点
当前提交
dcc659215e
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 16 次插入0 次删除
  1. 16
    0
      react/features/virtual-background/components/VirtualBackgroundPreview.js

+ 16
- 0
react/features/virtual-background/components/VirtualBackgroundPreview.js 查看文件

78
         };
78
         };
79
     }
79
     }
80
 
80
 
81
+    /**
82
+     * Destroys the jitsiTrack object.
83
+     *
84
+     * @param {Object} jitsiTrack - The track that needs to be disposed.
85
+     * @returns {Promise<void>}
86
+     */
87
+    _stopStream(jitsiTrack) {
88
+        if (jitsiTrack) {
89
+            jitsiTrack.dispose();
90
+        }
91
+    }
92
+
81
     /**
93
     /**
82
      * Creates and updates the track data.
94
      * Creates and updates the track data.
83
      *
95
      *
89
             devices: [ 'video' ]
101
             devices: [ 'video' ]
90
         });
102
         });
91
 
103
 
104
+
92
         // In case the component gets unmounted before the tracks are created
105
         // In case the component gets unmounted before the tracks are created
93
         // avoid a leak by not setting the state
106
         // avoid a leak by not setting the state
94
         if (this._componentWasUnmounted) {
107
         if (this._componentWasUnmounted) {
108
+            this._stopStream(jitsiTrack);
109
+
95
             return;
110
             return;
96
         }
111
         }
97
         this.setState({
112
         this.setState({
178
      */
193
      */
179
     componentWillUnmount() {
194
     componentWillUnmount() {
180
         this._componentWasUnmounted = true;
195
         this._componentWasUnmounted = true;
196
+        this._stopStream(this.state.jitsiTrack);
181
     }
197
     }
182
 
198
 
183
     /**
199
     /**

正在加载...
取消
保存