Pārlūkot izejas kodu

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 6 gadus atpakaļ
vecāks
revīzija
c0a8a386a5
1 mainītis faili ar 6 papildinājumiem un 4 dzēšanām
  1. 6
    4
      react/features/video-layout/subscriber.js

+ 6
- 4
react/features/video-layout/subscriber.js Parādīt failu

1
 // @flow
1
 // @flow
2
 
2
 
3
+import debounce from 'lodash/debounce';
4
+
3
 import {
5
 import {
4
     VIDEO_QUALITY_LEVELS,
6
     VIDEO_QUALITY_LEVELS,
5
     setMaxReceiverVideoQuality
7
     setMaxReceiverVideoQuality
44
 
46
 
45
 /**
47
 /**
46
  * For auto-pin mode, listen for changes to the known media tracks and look
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
 StateListenerRegistry.register(
52
 StateListenerRegistry.register(
50
     /* selector */ state => state['features/base/tracks'],
53
     /* selector */ state => state['features/base/tracks'],
51
-    /* listener */ (tracks, store) => {
54
+    /* listener */ debounce((tracks, store) => {
52
         if (!AUTO_PIN_LATEST_SCREEN_SHARE) {
55
         if (!AUTO_PIN_LATEST_SCREEN_SHARE) {
53
             return;
56
             return;
54
         }
57
         }
88
 
91
 
89
             _updateAutoPinnedParticipant(store);
92
             _updateAutoPinnedParticipant(store);
90
         }
93
         }
91
-    }
92
-);
94
+    }, 100));
93
 
95
 
94
 /**
96
 /**
95
  * Private helper to automatically pin the latest screen share stream or unpin
97
  * Private helper to automatically pin the latest screen share stream or unpin

Notiek ielāde…
Atcelt
Saglabāt