You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Move websocket network connection creation to the resource task #6638
A-content/domInteracting with the DOM from web contentA-networkC-assignedThere is someone working on resolving the issueE-more-complexVariable effort required; may require a mentor. Recommended solution is clearly described in the iss
In the multiprocess world we can't initiate connections from the content process. Additionally, we need the initial websocket upgrade request to include things like cookies, etc. We need to add a new network protocol handler that takes care of all of this. The first step here is to simply move the connection creation out of the WebSocket constructor; we can leave the integration with the HTTP code for another time.
I'm willing to pick this up since I've hacked a bit on resource_task.rs already, but I'm not sure I understand what you're suggesting. Is the suggestion to move/recreate establish_a_websocket_connection in components/script/dom/websocket.rs to components/net/resource_task.rs, then instead of calling it in WebSocket::new, pass in the WebSocketResult as an argument?
We can't allow network connections from the content sandbox? It seems a bit weird to proxy all this through some other process, although I guess if Gecko is single threaded for i/o this isn't much different to that.
Won't this prevent anyone from writing any high performance websocket code? That's a lot of data copying to go from JS to outside JS to another process and then into the final socket buffer and then all the way back for the reply.
We may be able to send the socket descriptors to the content process after the connection is initiated. I haven't looked closely at what Gecko does for websockets in particular.
For those following along at home, this is the plan I proposed to @nfallen:
Extract the websocket networking code (ie. making a connection, receiving data, and sending data) out of components/script/dom/websocket.rs and into components/net/websocket_loader.rs (which doesn't exist). This will require communicating with the resource task (components/net/resource_task.rs) to instruct it to initiate a new websocket connection, and providing an API that allows receiving feedback about this process (and subsequently sending and receiving data)
I imagine this requiring a new message in the ControlMsg enum in components/net_traits/lib.rs similar to the existing Load message
The new message should take an IpcSender argument that would allow the DOM websocket code to listen for the result of the connection
Extract the code in load in http_loader.rs that specifically deals with modifying the headers for a request into a separate function. Similarly, extract the code that deals with processing the headers for a response into a separate function.
Use the new methods on the headers fields in the Request and Response types that exist in the websocket network connection code that now lives in websocket_loader.rs
I am running the tests in wpt/web-platform-tests/websockets now. When they are run all together, one test times out every time, but when I run smaller subsets of the tests they all pass. Do you think this is just because of the decrease in performance of this implementation? Are there any other tests I should be running before creating a pull request?
Huh, that's really interesting. Easiest way to figure it out is to run the tests against a revision without your changes and see if there's a change in behaviour. You can also try build with --release and running the tests with --release to see if there's a difference.
A different test timed out each time that I ran ./mach test-wpt websockets. However, the most recent time I ran the tests, they all passed. Must be dependent on the CPU usage of my OS as I'm running the tests or something?
Plausible! If you think the work's ready, please make a pull request so we can start reviewing! If not, but you'd like another set of eyes to look at this timing out thing, please push your code to a branch of your fork and link it here.
A-content/domInteracting with the DOM from web contentA-networkC-assignedThere is someone working on resolving the issueE-more-complexVariable effort required; may require a mentor. Recommended solution is clearly described in the iss
Activity
samfoo commentedon Jul 16, 2015
I'm willing to pick this up since I've hacked a bit on
resource_task.rsalready, but I'm not sure I understand what you're suggesting. Is the suggestion to move/recreateestablish_a_websocket_connectionin components/script/dom/websocket.rs to components/net/resource_task.rs, then instead of calling it inWebSocket::new, pass in theWebSocketResultas an argument?Ms2ger commentedon Jul 16, 2015
Please don't pick it up just yet; I'm still working on that code.
metajack commentedon Jul 16, 2015
We can't allow network connections from the content sandbox? It seems a bit weird to proxy all this through some other process, although I guess if Gecko is single threaded for i/o this isn't much different to that.
jdm commentedon Jul 16, 2015
Gecko does the same. It's also important for things like network cache coherence, cookies, etc.
metajack commentedon Jul 16, 2015
Won't this prevent anyone from writing any high performance websocket code? That's a lot of data copying to go from JS to outside JS to another process and then into the final socket buffer and then all the way back for the reply.
jdm commentedon Jul 16, 2015
We may be able to send the socket descriptors to the content process after the connection is initiated. I haven't looked closely at what Gecko does for websockets in particular.
metajack commentedon Jul 16, 2015
That sounds satisfactory.
nfallen commentedon Oct 27, 2015
I can work on this!
jdm commentedon Oct 27, 2015
For those following along at home, this is the plan I proposed to @nfallen:
IpcSenderargument that would allow the DOM websocket code to listen for the result of the connectionExtract the code in
loadin http_loader.rs that specifically deals with modifying the headers for a request into a separate function. Similarly, extract the code that deals with processing the headers for a response into a separate function.Use the new methods on the
headersfields in the Request and Response types that exist in the websocket network connection code that now lives in websocket_loader.rs11 remaining items
nfallen commentedon Dec 7, 2015
I am running the tests in wpt/web-platform-tests/websockets now. When they are run all together, one test times out every time, but when I run smaller subsets of the tests they all pass. Do you think this is just because of the decrease in performance of this implementation? Are there any other tests I should be running before creating a pull request?
jdm commentedon Dec 7, 2015
Huh, that's really interesting. Easiest way to figure it out is to run the tests against a revision without your changes and see if there's a change in behaviour. You can also try build with
--releaseand running the tests with--releaseto see if there's a difference.jdm commentedon Dec 7, 2015
And no, those WPT tests should be all that's necessary.
nfallen commentedon Dec 7, 2015
Yep, I tried those things! The build from master did not time out, but the release build from my branch still had the same issue.
jdm commentedon Dec 7, 2015
It's quite interesting that the test doesn't time out when run in the group. Which one is it?
nfallen commentedon Dec 7, 2015
A different test timed out each time that I ran ./mach test-wpt websockets. However, the most recent time I ran the tests, they all passed. Must be dependent on the CPU usage of my OS as I'm running the tests or something?
jdm commentedon Dec 7, 2015
Plausible! If you think the work's ready, please make a pull request so we can start reviewing! If not, but you'd like another set of eyes to look at this timing out thing, please push your code to a branch of your fork and link it here.
Auto merge of #8867 - nfallen:6638-websocket_loader, r=jdm
KiChjang commentedon Jan 9, 2016
Is this still pending on the extraction of websocket connection algorithms out of websocket.rs and into websocket_loader.rs?
jdm commentedon Jan 9, 2016
I'll file new issues for any remaining pieces.
servo: Merge #8867 - Move websocket creation to resource task (from n…
servo: Merge #8867 - Move websocket creation to resource task (from n…
servo: Merge #8867 - Move websocket creation to resource task (from n…
servo: Merge #8867 - Move websocket creation to resource task (from n…