-
Couldn't load subscription status.
- Fork 859
Data channel message size limitations #702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data channel message size limitations #702
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
|
CLAs look good, thanks! |
src/js/common_shim.js
Outdated
| // Note: 65535 bytes is the default value from the SDP spec. Also, | ||
| // every implementation we know supports receiving 65535 bytes. | ||
| var maxMessageSize = 65535; | ||
| var match = arguments[0].sdp.match(/a=max-message-size:\s*(\d+)/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might consider requiring sdp and using matchPrefix -- its a sub-dependency of the edge shim currently so wouldn't increase "binary size"
|
This PR has a few issues I've detected. I'll tick them one by one and then it's ready to be merged (from my side):
|
|
The new tests should be fine now but Travis is still failing (in other tests) - ideas? |
|
FWIW, here's a list of determined
Couldn't test Safari as I don't own any Apple products. |
|
There's one last quirk remaining: I don't know why FF >= 57 doesn't raise an exception in the tests when sending a message that's too large. It does behave correctly when testing this by hand. |
|
I'm done. Can be reviewed. Some FF stable test timed out on Travis and needs to be restarted (runs fine locally). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice add, and nice tests, but I worry about the tests that have started failing with AssertionError, where you just patched the expected files (test/e2e/expectations/chrome-beta).
| }; | ||
|
|
||
| var getFirefoxVersion = function(description) { | ||
| // TODO: Is there a better solution for detecting Firefox? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is for detecting the remote browser's Firefox version, please call it detectRemoteFirefoxVersion. For local browser, we have utils.detectBrowser().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
| var getCanSendMaxMessageSize = function(description, remoteIsFirefox) { | ||
| // Every implementation we know can send at least 64 KiB. | ||
| // Note: Although Chrome is technically able to send up to 256 KiB, the | ||
| // data does not reach the other peer reliably. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have an issue number for Chrome here, please add it. (If not, please please please file one!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'll check if there is one already or file it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracked here
test/e2e/expectations/chrome-beta
Outdated
| PASS addTrack throws an exception if the track has already been added | ||
| PASS addTrack throws an exception if the track has already been added via addStream | ||
| PASS addTrack throws an exception if addStream is called with a stream containing a track already added | ||
| ERR addTrack throws an exception if addStream is called with a stream containing a track already added AssertionError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have these tests started failling with the patch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it wasn't my intention to commit this. There was an issue with tests but @fippo told me it might have been a new Chrome beta version. I'll rebase against master and we'll see if it works.
| /^a=max-message-size:\s*(\d+)\s*$/gm, ''); | ||
| description.sdp = description.sdp.replace( | ||
| /(^m=application\s+\d+\s+[\w\/]*SCTP.*$)/m, | ||
| '$1\r\na=max-message-size:' + maxMessageSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this insert a second max-message-size line into your SDP if it already has one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the replace in line 40 will remove the entire a=max-message-size line if there is one.
| it('send largest possible single message', () => { | ||
| // Note: Patching to 65535 here as anything beyond that will take too long. | ||
| const maxMessageSize = 65535; | ||
| const patchMaxMessageSize = patchMaxMessageSizeFactory(maxMessageSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this test always fail if the negotiated size is < 65535?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The short answer is yes, but it's a little bit more complicated than that. Every implementation supports 64 KiB unless one that doesn't handle EOR correctly fiddles with usrsctp's buffer sizes (256 KiB send/receive buffer by default results in the partial delivery size of 64 KiB) which no one has done so far. But there's at least one case where the negotiated size is 16 KiB (Firefox to Chrome). That's not a problem here because these tests will always create a peer connection with the same browser.
| // Note: 65535 bytes is the default value from the SDP spec. Also, | ||
| // every implementation we know supports receiving 65535 bytes. | ||
| var maxMessageSize = 65535; | ||
| var match = SDPUtils.matchPrefix(description.sdp, 'a=max-message-size:'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is the sdp package imported? I don't understand why this works ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was already imported. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does github not show it in the diff? Also note that you need to add it to package.json, currently it is a child dependeny
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I didn't add it. It was already there. It looks like it is in package.json already? https://github.com/webrtc/adapter/blob/master/package.json#L23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need new 👓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries. Me too. 😁 And it's better to double-check.
ba8c0fa to
7ac36d9
Compare
|
Rebased against master. |
src/js/common_shim.js
Outdated
| } | ||
|
|
||
| var sctpInDescription = function(description) { | ||
| var match = description.sdp.match(/m=application\s+\d+\s+[\w/]*SCTP/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about this:
var sections = SDPUtils.splitSections(description.sdp);
sections.shift();
return sections.some(function(mediaSection) {
var mLine = SDPUtils.parseMLine(mediaSection);
return mLine && mLine.kind === 'application'
&& mLine.protocol === 'DTLS/SCTP';
});
if we have SDPUtils anyway... needs a min version of 2.4.0 however
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I don't mind either solutions. Be aware that it may not always be DTLS/SCTP but also UDP/DTLS/SCTP and TCP/DTLS/SCTP, see: https://tools.ietf.org/html/draft-ietf-mmusic-sctp-sdp-26#section-4.2
|
Someone modified the DTMF test to use a transceiver. Transceivers aren't in Chrome stable. |
|
@alvestrand no. The transceiver check fails (https://travis-ci.org/webrtc/adapter/jobs/299697848#L2760) but that is in the expectation file. The DTMF/addTrack test which fails against expectation has been flaky (on travis) for quite some time. More so with experimental webplatform features if I recall correctly. Hitting rerun (which requires commit bit unfortunately) a couple of times usually solves it :-/ (I would only do so after squashing) |
|
Anything left preventing this from being merged? |
|
Set for major release since this a new shim? |
|
minor version is for new features. Unless 🐔 🐔 🐔 |
|
Edit: I just found a minor bug: The default MMS should be Edit: This also affects FF >= 57. If we can't get a backport fix, this PR will need updating once more. |
|
FF 57 will not be fixed, so I'll add a fix to this PR. |
|
Some tests disconnected and need to be restarted. (Some still fail in other places but I guess you know that already as it's also happening on master.) |
Fix handle maxMessageSize 0 case properly Fix handle corner case for maxMessageSize when sending from FF to FF Fix handle yet another corner case for maxMessageSize when sending from FF < 57 (uses 16 KiB chunks)
… well There's a bug in the implementation of FF 57, so DOMError is raised instead of TypeError. I hope we can land a hotfix for that but it shouldn't prevent us from merging this now.
…ror (apparently, I've misinterpreted the spec and this is how it should be done) Fix max message size tests
…l maximum message size at all) Remove MMS 0 case test (not really applicable to an e2e test)
… messages of arbitrary size
…n various combinations Fix default remote maximum message size for Firefox Fix default remote message size for Firefox 57 Don't apply the 'send' shim to Firefox >= 57 Export commonShim to window.adapter as well
b88320b to
ded8522
Compare
|
Rebased against master. |
Add a MMS test for subsequent data channels The send shim has been re-enabled for Firefox >= 57 due to the following bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1426831
Update expected MMS for FF >= 57
|
Resolved the problem with the test. It turned out to be a bug in Firefox and I had to dramatically decrease the maximum message size. Please, don't be irritated by me adding more commits. It's just that I didn't want to hold back these changes. It's good to merge now (from my side) and I'll backlog further changes in another branch until this is getting merged. Edit: URL fixed. |
|
finding bugs by writing code... 👍 👍 👍 |
|
@alvestrand any thoughts? |
|
Looks good to me, and the "update branch" button worked (for a wonder). I'll merge it once the checks complete. |
Recent changes in the W3C spec will ensure that a
TypeErroris thrown in casea data channel message is being sent that is too large for the other peer to
receive. However, that size limitation needs to be available to the sender or
it's an annoying guessing game.
This PR adds both access to
maxMessageSizeand throws aTypeErrorin casethe message is too large for the other peer to receive.