RTCDataChannel.bufferedAmount is updated too soon after sending data
Categories
(Core :: WebRTC: Signaling, defect, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox68 | --- | fixed |
People
(Reporter: bwc, Assigned: bwc)
References
Details
Attachments
(5 files)
The spec says:
"Even though the data transmission can occur in parallel, the returned value MUST NOT be decreased before the current task yielded back to the event loop to prevent race conditions."
This is causing failures in testing/web-platform/tests/webrtc/RTCDataChannel-bufferedAmount.html
It seems that we need to cache this value on main, increase it when calling send(), and decrease it by dispatching events to main.
| Assignee | ||
Comment 1•7 years ago
|
||
| Assignee | ||
Updated•7 years ago
|
Updated•7 years ago
|
| Assignee | ||
Comment 2•7 years ago
|
||
Depends on D28259
| Assignee | ||
Comment 3•7 years ago
|
||
Depends on D28525
| Assignee | ||
Comment 4•7 years ago
|
||
Depends on D28526
| Assignee | ||
Comment 5•7 years ago
|
||
| Assignee | ||
Comment 6•7 years ago
|
||
| Assignee | ||
Comment 7•7 years ago
|
||
| Assignee | ||
Comment 8•7 years ago
|
||
Still seeing failures on linux mochitest. Probably some timing bug.
| Assignee | ||
Comment 9•7 years ago
|
||
| Assignee | ||
Comment 10•7 years ago
|
||
Yeah, mochitest on linux is seeing failures on try, but I cannot reproduce on linux locally. Going to need to figure this out via code inspection.
| Assignee | ||
Comment 11•7 years ago
|
||
At least part of this is bad code in pc.js, but it is not that simple.
| Assignee | ||
Comment 12•7 years ago
|
||
| Assignee | ||
Comment 13•7 years ago
|
||
| Assignee | ||
Comment 14•7 years ago
|
||
| Assignee | ||
Comment 15•7 years ago
|
||
| Assignee | ||
Comment 16•7 years ago
|
||
Ok, none of the usual ways to enable logging on try are working.
This patch does not make it happen:
https://hg.mozilla.org/try/rev/153184fa3292751223ddb562093cd1b7c1b02dbe
Nor does passing a MOZ_LOG env variable to mach try like so:
--env="MOZ_LOG=DataChannel:5"
I'm going to need to hard-code a modification to the logging system, I think.
ahal, is there some new way of doing this?
| Assignee | ||
Comment 17•7 years ago
|
||
Right. So even after hard-coding the logging system to use DataChannel at 5, there's still no logging output in those try runs. I'm going to guess that MOZ_LOG is just not logging on try right now. R_LOG seems to work, so maybe printf will work.
Comment 18•7 years ago
|
||
I'm not familiar with Gecko's logging systems. Maybe someone replaced the MOZ_LOG env and forgot to change mochitest? Though I don't recall any announcements to that effect. Does setting MOZ_LOG locally still work? I can't think what would be different on try vs local.
| Assignee | ||
Comment 19•7 years ago
|
||
MOZ_LOG locally still works. Something is filtering out or disabling MOZ_LOG on try however.
| Assignee | ||
Comment 20•7 years ago
|
||
It really does looks like DataChannel messages are being processed by the receiver so quickly on linux that they often are processed before the sender can dispatch an update to the buffered amount on main. This seems to be caused by the fact that we are calling usrsctp_sendv on main most of the time. What must be happening is as follows:
- Call usrsctp_sendv on main, from the JS callstack that called send.
- This causes a dispatch to STS to actually send the packet, that begins processing right away and sends.
- STS receives the packet, and hands it off to the SCTP stack.
- SCTP stack dispatches the received message to main.
- The stack that called usrsctp_sendv (see step 1) has not returned yet, and dispatches an update to the buffered amount.
I think I can work around this by moving the work in step 5 off of main, and do it during step 2.
| Assignee | ||
Comment 21•7 years ago
|
||
It would be really nice if the sctp conn_output callback gave us the amount of non-SCTP data in that packet. That would make it easy to fix this problem, and would also allow us to give a better estimate of how much data was buffered; right now we don't count any data that is buffered in usrsctp.
How hard would it be to implement something like this? Alternately, is there a utility function that can count the amount of non-SCTP data in an SCTP packet?
Comment 22•7 years ago
|
||
Hi Byron,
my understanding is that bufferedAmount is the number of bytes the application has given to the JS layer via the send method, which is buffered with the JS layer or the SCTP layer and which is not sent yet. I think we can avoid looking at the DTLS layer...
However, it is incremented when the user calls send() and is decremented when the data is sent the first time. Do we agree on this?
Assuming that we do, I don't think the functionality you are asking for is really giving you the correct values. The point is that you not only need to know how many bytes of user data are in an SCTP packet, but how many bytes of user data, which are not retransmissions are in the packet. This is something you can't simply deduce by parsing the packet again.
I think what you need is
(a) keep track of the number of bytes queued in the JS layer.
(b) a way to ask the SCTP stack, how many unsent bytes are queued for a specific SCTP stream.
The sum of (a) and (b) gives you what you want. Is my understanding correct?
Implementing (b) requires some additional stat counters in the SCTP stack and a new socket option to
retrieve these numbers. I guess this has to be added to the SCTP stack. I can try to implement this.
However, it might take some time (lets say until the next IETF or so) to get it implemented.
Does this help?
| Assignee | ||
Comment 23•7 years ago
|
||
That would be useful, yes. I'm not going to block this bug on that, since it isn't a huge deal for the decrease in bufferedAmount to happen a little early.
| Assignee | ||
Comment 24•7 years ago
|
||
| Assignee | ||
Comment 25•7 years ago
|
||
| Assignee | ||
Comment 26•7 years ago
|
||
| Assignee | ||
Comment 27•7 years ago
|
||
Depends on D28528
| Assignee | ||
Comment 28•7 years ago
|
||
| Assignee | ||
Comment 29•7 years ago
|
||
Seeing some sort of infra problem on that try push. Retriggering some stuff.
| Assignee | ||
Comment 30•7 years ago
|
||
Try looks fine after the retriggers.
Comment 31•7 years ago
|
||
Comment 32•7 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/f19730eee267
https://hg.mozilla.org/mozilla-central/rev/138bf6e11c05
https://hg.mozilla.org/mozilla-central/rev/2375b78d0f7a
https://hg.mozilla.org/mozilla-central/rev/5ea4e8902e7e
https://hg.mozilla.org/mozilla-central/rev/074678d618bb
Description
•