RESOLVED FIXED 173120
Filter SDP from ICE candidates in case of local ICE candidate filtering
https://bugs.webkit.org/show_bug.cgi?id=173120
Summary Filter SDP from ICE candidates in case of local ICE candidate filtering
youenn fablet
Reported 2017-06-08 15:46:40 PDT
Filter SDP from ICE candidates in case of local ICE candidate filtering
Attachments
Patch (11.25 KB, patch)
2017-06-08 16:03 PDT, youenn fablet
no flags
Patch (17.36 KB, patch)
2017-06-11 11:42 PDT, youenn fablet
no flags
youenn fablet
Comment 1 2017-06-08 16:03:11 PDT
Jon Lee
Comment 2 2017-06-08 19:00:00 PDT
Comment on attachment 312358 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=312358&action=review > LayoutTests/webrtc/datachannel/filter-ice-candidate.html:47 > + assert_equals(pc.localDescription.sdp.indexOf("a:=candidate"), -1); shouldn't this be a=candidate ?
Jon Lee
Comment 3 2017-06-08 21:44:32 PDT
Eric Carlson
Comment 4 2017-06-09 08:56:20 PDT
Comment on attachment 312358 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=312358&action=review > Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp:47 > +String filterICECandidate(String&&); Nit: This can be static. >> LayoutTests/webrtc/datachannel/filter-ice-candidate.html:47 >> + assert_equals(pc.localDescription.sdp.indexOf("a:=candidate"), -1); > > shouldn't this be a=candidate ? I agree.
Jon Lee
Comment 5 2017-06-09 09:51:46 PDT
Comment on attachment 312358 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=312358&action=review >> Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp:47 >> +String filterICECandidate(String&&); > > Nit: This can be static. I think you can revert this... > Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp:306 > +String filterICECandidate(String&& sdp) ... and this. > LayoutTests/webrtc/datachannel/filter-ice-candidate.html:34 > + }); I'm confused by these tests. Above there are potentially two resolve() calls. Is that right? Why is filtering set to true in this block, and not set in the next promise_test(), for parallelism?
Jon Lee
Comment 6 2017-06-09 09:53:04 PDT
Comment on attachment 312358 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=312358&action=review >> LayoutTests/webrtc/datachannel/filter-ice-candidate.html:34 >> + }); > > I'm confused by these tests. Above there are potentially two resolve() calls. Is that right? Why is filtering set to true in this block, and not set in the next promise_test(), for parallelism? It seems that the test isn't reaching some of these asserts. I am able to change the assertions to clearly wrong conditions, and the test still passes.
youenn fablet
Comment 7 2017-06-09 10:47:42 PDT
Comment on attachment 312358 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=312358&action=review >>> LayoutTests/webrtc/datachannel/filter-ice-candidate.html:34 >>> + }); >> >> I'm confused by these tests. Above there are potentially two resolve() calls. Is that right? Why is filtering set to true in this block, and not set in the next promise_test(), for parallelism? > > It seems that the test isn't reaching some of these asserts. I am able to change the assertions to clearly wrong conditions, and the test still passes. The second resolve is a noop and should be removed. We could change the place where we set the filtering to true. That might be indeed clearer but will not change any behavior here. Can you explain which assertions you changed?
youenn fablet
Comment 8 2017-06-10 16:01:36 PDT
Comment on attachment 312358 [details] Patch I l clean the tests to make them more readable. Putting patch in r? in the meantime.
Sam Weinig
Comment 9 2017-06-10 19:19:28 PDT
Comment on attachment 312358 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=312358&action=review > Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp:355 > + Vector<String> lines; > + sdp.split('\n', false, lines); > + > + StringBuilder builder; > + for (auto& line : lines) { > + if (!line.contains("a=candidate")) > + builder.append(line); > + else if (!line.contains(" host ")) > + builder.append(filterICECandidate(WTFMove(line))); > + else > + continue; > + builder.append('\n'); > + } > + return builder.toString(); I'm not sure how hot this is, but a lot of unnecessary String allocations are taking place. A split that took a functor, something like spd.split('\n', false, [] (StringView line) { }) would allow many fewer allocations. (See splitOnSpaces in SubresourceIntegrity.cpp for non-generalized version of this).
youenn fablet
Comment 10 2017-06-11 11:42:09 PDT
youenn fablet
Comment 11 2017-06-11 11:45:49 PDT
> I'm not sure how hot this is, but a lot of unnecessary String allocations > are taking place. A split that took a functor, something like > spd.split('\n', false, [] (StringView line) { }) would allow many fewer > allocations. (See splitOnSpaces in SubresourceIntegrity.cpp for > non-generalized version of this). It is not very hot, it will happen once for a webrtc page typically. But this is a good idea anyway and some other places might benefit from it as well. Patch adds a split helper routine here. In the same patch, I cleaned the tests as discussed above. I added an additional assert after candidates have been gathered.
WebKit Commit Bot
Comment 12 2017-06-13 01:13:29 PDT
Comment on attachment 312613 [details] Patch Clearing flags on attachment: 312613 Committed r218168: <http://trac.webkit.org/changeset/218168>
WebKit Commit Bot
Comment 13 2017-06-13 01:13:31 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.