File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
p2p/src/service_impl/webrtc Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -184,13 +184,17 @@ impl Drop for RTCChannel {
184
184
}
185
185
}
186
186
187
- async fn wait_for_ice_gathering_complete ( pc : & RTCConnection ) {
188
- let timeout = Duration :: from_secs ( 3 ) ;
189
-
187
+ async fn sleep ( dur : Duration ) {
190
188
#[ cfg( not( target_arch = "wasm32" ) ) ]
191
- let timeout = tokio:: time:: sleep ( timeout ) ;
189
+ let fut = tokio:: time:: sleep ( dur ) ;
192
190
#[ cfg( target_arch = "wasm32" ) ]
193
- let timeout = gloo_timers:: future:: TimeoutFuture :: new ( timeout. as_millis ( ) as u32 ) ;
191
+ let fut = gloo_timers:: future:: TimeoutFuture :: new ( dur. as_millis ( ) as u32 ) ;
192
+ fut. await
193
+ }
194
+
195
+ async fn wait_for_ice_gathering_complete ( pc : & RTCConnection ) {
196
+ let timeout = sleep ( Duration :: from_secs ( 3 ) ) ;
197
+
194
198
tokio:: select! {
195
199
_ = timeout => { }
196
200
_ = pc. wait_for_ice_gathering_complete( ) => { }
@@ -513,6 +517,11 @@ async fn peer_loop(
513
517
let chan_clone = chan. clone ( ) ;
514
518
let event_sender_clone = event_sender. clone ( ) ;
515
519
spawn_local ( async move {
520
+ // Add a delay for sending messages after channel
521
+ // was opened. Some initial messages get lost otherwise.
522
+ // TODO(binier): find deeper cause and fix it.
523
+ sleep ( Duration :: from_secs ( 3 ) ) . await ;
524
+
516
525
while let Some ( ( msg_id, encoded) ) = sender_rx. recv ( ) . await {
517
526
let encoded = bytes:: Bytes :: from ( encoded) ;
518
527
let mut chunks =
You can’t perform that action at this time.
0 commit comments