kripken / BananaBread

BananaBread is a C++ 3D game engine that runs on the web using JavaScript+WebGL+HTML
1.38k stars 347 forks source link

WebRTC stacks up messages when receiving data 30x per second in Firefox #43

Open myusernameiscewl opened 10 years ago

myusernameiscewl commented 10 years ago

Steps to reproduce:

In firefox the listener doesn't work well, when receiving messages 30x per second. The listener is called at inconsistent times. This can be checked with Date now().

To reproduce it:

  1. Make a connection between two peer in two different tabs.
  2. Let one or both send data at 30x per second rate.
  3. 'on('data') -> console.log(Date.now());' In Chrome everything works as aspected.

I tested it using PeerJS. The bug has nothing to do with PeerJS itself. It's when using DTLS in firefox.

Actual results:

You will see something like this in firebug (millisecond times):

1392036772332
CLIENT.html (line 870)

1392036772334
CLIENT.html (line 870)

1392036772337
CLIENT.html (line 870)

1392036772340
CLIENT.html (line 870)

1392036772342
CLIENT.html (line 870)

1392036772345
CLIENT.html (line 870)

1392036772546
CLIENT.html (line 870)

1392036772548
CLIENT.html (line 870)

There are 200 millisecond skips every ~4 messages. Sending does work and is called 30x per second.

Expected results:

Receive messages at consistent times. How would a multiplayer game like banana bread be possible if not?

In chrome this works but Firefox to chrome or chrome to Firefox or Firefox to Firefox it doesn't work either. Not even in the canary/nightly versions!

Did I do something wrong?

kripken commented 10 years ago

cc @modeswitch who wrote this

myusernameiscewl commented 10 years ago

I also tried it following this guide: https://developer.mozilla.org/en-US/docs/Web/Guide/API/WebRTC/WebRTC_basics

And changing this demo, so it would send data at 30x per second: http://louisstow.github.io/WebRTC/datachannels.html (demo linked to from above WebRTC basics URL)

I also posted the issue on bugzilla here, but I didn't get a single reaction: https://bugzilla.mozilla.org/show_bug.cgi?id=970610

And it seems to happen in both reliable and unreliable connections. I tested unreliable by setting maxRetransmitnum = 0, reliable = false and ordered = false.

So is this issue confirmed now?

Any idea when this is going to be resolved?

modeswitch commented 10 years ago

BananaBread performs well even at higher latency.

It's unclear from your report above whether this is causing a bug in BananaBread. If not, the correct place to track this is in bugzilla.

myusernameiscewl commented 10 years ago

Yes but Banana Bread still uses the fake audio/video stream (which doesn't interoperate) and not DTLS dataChannel which does interoperate with Chrome. So this might be a problem for Banana Bread in the future.

Also the new WebRTC version of WebRTC on Firefox seems to use far less CPU (if it's not a problem caused by my laptop) than the one with the fake media stream.

I also posted it on bugzilla but nobody seems to either see it or do something about it. And that makes me sad, because I'm so excited and interested about the things you and Mozilla are doing. And then this single bug stops me, from showing and convincing other people in a beautiful and interopable way how great these web technologies you and Mozilla work on are.

I hope maybe one of you could contact someone who is working on the implementation of WebRTC on Firefox.

kripken commented 10 years ago

Link to bugzilla bug report?

myusernameiscewl commented 10 years ago

https://bugzilla.mozilla.org/show_bug.cgi?id=970610

The bug report stated here on GitHub is more complete.

kripken commented 10 years ago

Thanks, let's continue discussion there.