Procházet zdrojové kódy

fix(pinning): debounce autopin subscriber

The store's remote tracks get cleared
and re-added when switching in and out
of p2p, which can cause pinning thrashing.
Avoid that with a debounce.
master
Leonard Kim před 6 roky
rodič
revize
c0a8a386a5
1 změnil soubory, kde provedl 6 přidání a 4 odebrání
  1. 6
    4
      react/features/video-layout/subscriber.js

+ 6
- 4
react/features/video-layout/subscriber.js Zobrazit soubor

@@ -1,5 +1,7 @@
1 1
 // @flow
2 2
 
3
+import debounce from 'lodash/debounce';
4
+
3 5
 import {
4 6
     VIDEO_QUALITY_LEVELS,
5 7
     setMaxReceiverVideoQuality
@@ -44,11 +46,12 @@ StateListenerRegistry.register(
44 46
 
45 47
 /**
46 48
  * For auto-pin mode, listen for changes to the known media tracks and look
47
- * for updates to screen shares.
49
+ * for updates to screen shares. The listener is debounced to avoid state
50
+ * thrashing that might occur, especially when switching in or out of p2p.
48 51
  */
49 52
 StateListenerRegistry.register(
50 53
     /* selector */ state => state['features/base/tracks'],
51
-    /* listener */ (tracks, store) => {
54
+    /* listener */ debounce((tracks, store) => {
52 55
         if (!AUTO_PIN_LATEST_SCREEN_SHARE) {
53 56
             return;
54 57
         }
@@ -88,8 +91,7 @@ StateListenerRegistry.register(
88 91
 
89 92
             _updateAutoPinnedParticipant(store);
90 93
         }
91
-    }
92
-);
94
+    }, 100));
93 95
 
94 96
 /**
95 97
  * Private helper to automatically pin the latest screen share stream or unpin

Načítá se…
Zrušit
Uložit