Bladeren bron

fix(virtual-background) fix track leak in preview

master
Tudor D. Pop 4 jaren geleden
bovenliggende
commit
dcc659215e
No account linked to committer's email address
1 gewijzigde bestanden met toevoegingen van 16 en 0 verwijderingen
  1. 16
    0
      react/features/virtual-background/components/VirtualBackgroundPreview.js

+ 16
- 0
react/features/virtual-background/components/VirtualBackgroundPreview.js Bestand weergeven

@@ -78,6 +78,18 @@ class VirtualBackgroundPreview extends PureComponent<Props, State> {
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 94
      * Creates and updates the track data.
83 95
      *
@@ -89,9 +101,12 @@ class VirtualBackgroundPreview extends PureComponent<Props, State> {
89 101
             devices: [ 'video' ]
90 102
         });
91 103
 
104
+
92 105
         // In case the component gets unmounted before the tracks are created
93 106
         // avoid a leak by not setting the state
94 107
         if (this._componentWasUnmounted) {
108
+            this._stopStream(jitsiTrack);
109
+
95 110
             return;
96 111
         }
97 112
         this.setState({
@@ -178,6 +193,7 @@ class VirtualBackgroundPreview extends PureComponent<Props, State> {
178 193
      */
179 194
     componentWillUnmount() {
180 195
         this._componentWasUnmounted = true;
196
+        this._stopStream(this.state.jitsiTrack);
181 197
     }
182 198
 
183 199
     /**

Laden…
Annuleren
Opslaan