kyren / webrtc-unreliable

Just enough hacks to get unreliable unordered WebRTC data channels between a browser and a server
Other
394 stars 29 forks source link

server::send seems to be delayed by 1 frame at random #26

Closed cybersoulK closed 1 year ago

cybersoulK commented 1 year ago

I send 2 datagrams at once to one connection, and 1 arrives earlier than the other, 2% of the time, giving it a jittery effect if they are moving in a line. (tested in localhost and remotely, firefox and chrome)

This is what i use:

` loop { let action = tokio::select! { msg = server.recv() => msg.map(|msg| { //... }).ok(), msg = send_merge_rx.recv() => msg.map(|(message_or_flush, remote_addr)| { //... }),
};

Action::Flush(remote_addr) => { for data in transport_layer.flush() { //<------ sends 2 here server.send(&data, MessageType::Binary, &remote_addr).await.ok();
} } }

cybersoulK commented 1 year ago

i tested with quinn on native, i also have this effect, but not "as much" by a factor of 5-10.

So i guess that could be due to the protocols behind, either on the server or the client webrtc.

(The two messages just need to arrive 2% behind each other to make the mismatch between server and client fps , and delay the updates by a whole frame)

Feel free to reopen if there is practical improvements that could be made to webrtc unreliable crate