Re: [whatwg/fetch] ReadableStream and in-parallel/event-loop integration question (#976)

> On the other hand, in Blink currently it doesn't work by queuing a task, and I worry that the difference might be visible.

How does it work in Blink(I've had a look but I'm not sure)?

> That seems like a good solution. I suppose the current text could be considered as shorthand for doing something like that, but it's not helpful for people who actually have to implement it.

I was mostly wondering when to start the reading workflow(acquire the reader, read a chunk via a promise, sent it over IPC to the networking when it resolves).

It could either be done when the request is first created, which would seem to assume the fetch isn't going to be terminated before it hits "transmit-body", or it can be done by queuing a task back on the event-loop as part of "transmit-body".

I've have a look at Gecko and Blink, it seems the [`FetchStreamReader`](https://searchfox.org/mozilla-central/source/dom/fetch/FetchStreamReader.h) in Gecko roughly corresponds to the [`BodyStreamBuffer`](https://github.com/chromium/chromium/blob/452afba8d3a59d2d256fa49fc7a925de302dbd11/third_party/blink/renderer/core/fetch/body_stream_buffer.h) in Blink.

For Gecko, it looks like the reading workflow start immediately in the request constructor, and I though it might be similar in Blink(`BodyStreamBuffer::OnStateChange` also seems to be called in the constructor of `BodyStreamBuffer`). 

On the other hand, in Servo, I was thinking of actually queuing a task back on the event-loop from the parallel "transmit body" steps, and then start the reading inside that task, as opposed to starting when the request is created.  

So it could be interesting to see if such differences could be noticeable to script, perhaps if the fetch is terminated "early", like in the same task it is initiated. If the reading were to be done in a task-queued as part of "transmit the body" in fetch, it would only be queued if the fetch hadn't been terminated before. 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/976#issuecomment-560472876

Received on Monday, 2 December 2019 16:32:13 UTC