WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
138968
[Fetch API] Consume HTTP data as a ReadableStream
https://bugs.webkit.org/show_bug.cgi?id=138968
Summary
[Fetch API] Consume HTTP data as a ReadableStream
youenn fablet
Reported
2014-11-21 09:13:43 PST
A web app should be able to consume HTTP response data as a stream as soon as possible. Amongst others, MSE may benefit from such feature.
Attachments
WIP
(47.89 KB, patch)
2014-11-24 01:19 PST
,
youenn fablet
no flags
Details
Formatted Diff
Diff
WIP
(20.09 KB, patch)
2014-11-24 01:20 PST
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(19.18 KB, patch)
2014-12-10 07:01 PST
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews101 for mac-mountainlion
(661.66 KB, application/zip)
2014-12-10 07:45 PST
,
Build Bot
no flags
Details
Archive of layout-test-results from webkit-ews-10 for mac-mountainlion-wk2
(648.48 KB, application/zip)
2014-12-10 08:19 PST
,
Build Bot
no flags
Details
Updated according ReadableStream implementation in JSC
(45.71 KB, patch)
2015-08-21 03:40 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
WIP
(65.52 KB, patch)
2016-03-21 11:51 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Rebasing
(67.53 KB, patch)
2016-03-24 09:13 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Rebased and more tests
(93.41 KB, patch)
2016-04-05 02:05 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews104 for mac-yosemite-wk2
(912.22 KB, application/zip)
2016-04-05 03:01 PDT
,
Build Bot
no flags
Details
Archive of layout-test-results from ews122 for ios-simulator-wk2
(563.87 KB, application/zip)
2016-04-05 03:16 PDT
,
Build Bot
no flags
Details
Archive of layout-test-results from ews114 for mac-yosemite
(897.99 KB, application/zip)
2016-04-05 03:24 PDT
,
Build Bot
no flags
Details
Adding conditional compilation and fixing tests
(101.18 KB, patch)
2016-04-05 06:11 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews104 for mac-yosemite-wk2
(770.81 KB, application/zip)
2016-04-05 07:06 PDT
,
Build Bot
no flags
Details
Archive of layout-test-results from ews123 for ios-simulator-wk2
(590.75 KB, application/zip)
2016-04-05 07:11 PDT
,
Build Bot
no flags
Details
Archive of layout-test-results from ews116 for mac-yosemite
(818.92 KB, application/zip)
2016-04-05 07:26 PDT
,
Build Bot
no flags
Details
Fixing stream-response.html
(101.61 KB, patch)
2016-04-05 15:26 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews104 for mac-yosemite-wk2
(1.03 MB, application/zip)
2016-04-05 16:22 PDT
,
Build Bot
no flags
Details
Archive of layout-test-results from ews121 for ios-simulator-wk2
(575.40 KB, application/zip)
2016-04-05 16:26 PDT
,
Build Bot
no flags
Details
Trying to fix response-stream-disturbed-4.html
(101.82 KB, patch)
2016-04-06 02:40 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(106.42 KB, patch)
2016-04-06 06:19 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
After review
(104.88 KB, patch)
2016-04-17 09:37 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Show Obsolete
(21)
View All
Add attachment
proposed patch, testcase, etc.
youenn fablet
Comment 1
2014-11-24 01:19:02 PST
Created
attachment 242148
[details]
WIP
youenn fablet
Comment 2
2014-11-24 01:20:51 PST
Created
attachment 242149
[details]
WIP
youenn fablet
Comment 3
2014-11-24 01:25:23 PST
(In reply to
comment #2
)
> Created
attachment 242149
[details]
> WIP
This patch illustrates how ReadableStream (as implemented in latest WIP patch from
bug 138967
) can be instantiated from XHR response.
Xabier Rodríguez Calvar
Comment 4
2014-11-24 01:46:51 PST
This depends on
bug 138967
, as this patch can't live without the other.
youenn fablet
Comment 5
2014-12-10 07:01:23 PST
Created
attachment 243013
[details]
Patch
youenn fablet
Comment 6
2014-12-10 07:02:03 PST
(In reply to
comment #5
)
> Created
attachment 243013
[details]
> Patch
Patch updates XHR integration according the latest ReadableStream API.
Build Bot
Comment 7
2014-12-10 07:45:52 PST
Comment on
attachment 243013
[details]
Patch
Attachment 243013
[details]
did not pass mac-ews (mac): Output:
http://webkit-queues.appspot.com/results/5988914837848064
New failing tests: http/tests/xmlhttprequest/streams/streams-read-api-closed.html http/tests/xmlhttprequest/streams/streams-read-api.html fast/xmlhttprequest/xmlhttprequest-responsetype-stream.html http/tests/xmlhttprequest/streams/streams-read.html http/tests/xmlhttprequest/streams/streams-read-api-cancelled.html
Build Bot
Comment 8
2014-12-10 07:45:56 PST
Created
attachment 243020
[details]
Archive of layout-test-results from ews101 for mac-mountainlion The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-mountainlion Platform: Mac OS X 10.8.5
Build Bot
Comment 9
2014-12-10 08:19:31 PST
Comment on
attachment 243013
[details]
Patch
Attachment 243013
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.appspot.com/results/5859343190720512
New failing tests: http/tests/xmlhttprequest/streams/streams-read-api-closed.html http/tests/xmlhttprequest/streams/streams-read-api.html fast/xmlhttprequest/xmlhttprequest-responsetype-stream.html http/tests/xmlhttprequest/streams/streams-read.html http/tests/xmlhttprequest/streams/streams-read-api-cancelled.html
Build Bot
Comment 10
2014-12-10 08:19:37 PST
Created
attachment 243024
[details]
Archive of layout-test-results from webkit-ews-10 for mac-mountainlion-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: webkit-ews-10 Port: mac-mountainlion-wk2 Platform: Mac OS X 10.8.5
youenn fablet
Comment 11
2014-12-11 02:51:28 PST
Comment on
attachment 243013
[details]
Patch Was not meant to be r?
youenn fablet
Comment 12
2015-08-21 03:40:09 PDT
Created
attachment 259598
[details]
Updated according ReadableStream implementation in JSC
youenn fablet
Comment 13
2015-08-21 07:35:27 PDT
(In reply to
comment #12
)
> Created
attachment 259598
[details]
> Updated according ReadableStream implementation in JSC
This is a mock-up version of how native ReadableStream sources could be implemented, not a real patch but it gives an idea. Basically, native sources would have an IDL that would implement the ReadableStream source API (start, pull and cancel). Similarly to promises, a WebCore wrapper around controller is introduced to more easily enqueue and error the streams with non-JS objects. Controller is kept as a cached attribute as this is not observable from JS scripts and it allows not using JSC::Strong.
youenn fablet
Comment 14
2016-03-21 11:51:28 PDT
Created
attachment 274614
[details]
WIP
youenn fablet
Comment 15
2016-03-24 09:13:23 PDT
Created
attachment 274835
[details]
Rebasing
youenn fablet
Comment 16
2016-03-24 09:13:58 PDT
(In reply to
comment #15
)
> Created
attachment 274835
[details]
> Rebasing
Patch probably needs more tests. Early feedback most welcome though.
Alex Christensen
Comment 17
2016-03-24 10:54:47 PDT
Comment on
attachment 274835
[details]
Rebasing View in context:
https://bugs.webkit.org/attachment.cgi?id=274835&action=review
Just a quick glance:
> Source/WebCore/Modules/fetch/FetchBody.cpp:191
This is what a switch statement is for.
> Source/WebCore/Modules/fetch/FetchBodyOwner.cpp:52 > +void FetchBodyOwner::stopBlobLoading()
This change doesn't seem useful.
> Source/WebCore/Modules/fetch/FetchLoader.cpp:107 > + RefPtr<SharedBuffer> data = WTFMove(m_data);
No need for a named variable here
WebKit Commit Bot
Comment 18
2016-03-24 10:58:18 PDT
Attachment 274835
[details]
did not pass style-queue: ERROR: Source/WebCore/Modules/fetch/FetchResponse.h:122: Should be indented on a separate line, with the colon or comma first on that line. [whitespace/indent] [4] ERROR: Source/WebCore/bindings/js/ReadableStreamController.h:43: Should be indented on a separate line, with the colon or comma first on that line. [whitespace/indent] [4] Total errors found: 2 in 28 files If any of these errors are false positives, please file a bug against check-webkit-style.
youenn fablet
Comment 19
2016-04-05 02:05:44 PDT
Created
attachment 275650
[details]
Rebased and more tests
WebKit Commit Bot
Comment 20
2016-04-05 02:10:06 PDT
Attachment 275650
[details]
did not pass style-queue: ERROR: Source/WebCore/Modules/fetch/FetchResponseSource.h:41: Should be indented on a separate line, with the colon or comma first on that line. [whitespace/indent] [4] ERROR: Source/WebCore/bindings/js/ReadableStreamController.h:45: Should be indented on a separate line, with the colon or comma first on that line. [whitespace/indent] [4] Total errors found: 2 in 38 files If any of these errors are false positives, please file a bug against check-webkit-style.
Build Bot
Comment 21
2016-04-05 03:01:05 PDT
Comment on
attachment 275650
[details]
Rebased and more tests
Attachment 275650
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.webkit.org/results/1102746
New failing tests: imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed.html
Build Bot
Comment 22
2016-04-05 03:01:09 PDT
Created
attachment 275653
[details]
Archive of layout-test-results from ews104 for mac-yosemite-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-yosemite-wk2 Platform: Mac OS X 10.10.5
Build Bot
Comment 23
2016-04-05 03:16:08 PDT
Comment on
attachment 275650
[details]
Rebased and more tests
Attachment 275650
[details]
did not pass ios-sim-ews (ios-simulator-wk2): Output:
http://webkit-queues.webkit.org/results/1102760
New failing tests: imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed.html
Build Bot
Comment 24
2016-04-05 03:16:13 PDT
Created
attachment 275654
[details]
Archive of layout-test-results from ews122 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews122 Port: ios-simulator-wk2 Platform: Mac OS X 10.10.5
Build Bot
Comment 25
2016-04-05 03:24:01 PDT
Comment on
attachment 275650
[details]
Rebased and more tests
Attachment 275650
[details]
did not pass mac-debug-ews (mac): Output:
http://webkit-queues.webkit.org/results/1102763
New failing tests: imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream.html imported/w3c/web-platform-tests/fetch/api/basic/stream-response.html
Build Bot
Comment 26
2016-04-05 03:24:06 PDT
Created
attachment 275656
[details]
Archive of layout-test-results from ews114 for mac-yosemite The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews114 Port: mac-yosemite Platform: Mac OS X 10.10.5
youenn fablet
Comment 27
2016-04-05 06:11:14 PDT
Created
attachment 275657
[details]
Adding conditional compilation and fixing tests
WebKit Commit Bot
Comment 28
2016-04-05 06:13:58 PDT
Attachment 275657
[details]
did not pass style-queue: ERROR: Source/WebCore/Modules/fetch/FetchResponseSource.h:41: Should be indented on a separate line, with the colon or comma first on that line. [whitespace/indent] [4] ERROR: Source/WebCore/bindings/js/ReadableStreamController.h:45: Should be indented on a separate line, with the colon or comma first on that line. [whitespace/indent] [4] Total errors found: 2 in 46 files If any of these errors are false positives, please file a bug against check-webkit-style.
Build Bot
Comment 29
2016-04-05 07:06:00 PDT
Comment on
attachment 275657
[details]
Adding conditional compilation and fixing tests
Attachment 275657
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.webkit.org/results/1103668
New failing tests: imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-4.html
Build Bot
Comment 30
2016-04-05 07:06:05 PDT
Created
attachment 275661
[details]
Archive of layout-test-results from ews104 for mac-yosemite-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-yosemite-wk2 Platform: Mac OS X 10.10.5
Build Bot
Comment 31
2016-04-05 07:10:57 PDT
Comment on
attachment 275657
[details]
Adding conditional compilation and fixing tests
Attachment 275657
[details]
did not pass ios-sim-ews (ios-simulator-wk2): Output:
http://webkit-queues.webkit.org/results/1103670
New failing tests: imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-4.html
Build Bot
Comment 32
2016-04-05 07:11:03 PDT
Created
attachment 275664
[details]
Archive of layout-test-results from ews123 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews123 Port: ios-simulator-wk2 Platform: Mac OS X 10.10.5
Build Bot
Comment 33
2016-04-05 07:25:56 PDT
Comment on
attachment 275657
[details]
Adding conditional compilation and fixing tests
Attachment 275657
[details]
did not pass mac-debug-ews (mac): Output:
http://webkit-queues.webkit.org/results/1103723
New failing tests: imported/w3c/web-platform-tests/fetch/api/basic/stream-response.html
Build Bot
Comment 34
2016-04-05 07:26:01 PDT
Created
attachment 275666
[details]
Archive of layout-test-results from ews116 for mac-yosemite The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews116 Port: mac-yosemite Platform: Mac OS X 10.10.5
youenn fablet
Comment 35
2016-04-05 15:26:18 PDT
Created
attachment 275703
[details]
Fixing stream-response.html
WebKit Commit Bot
Comment 36
2016-04-05 15:29:33 PDT
Attachment 275703
[details]
did not pass style-queue: ERROR: Source/WebCore/Modules/fetch/FetchResponseSource.h:41: Should be indented on a separate line, with the colon or comma first on that line. [whitespace/indent] [4] ERROR: Source/WebCore/bindings/js/ReadableStreamController.h:45: Should be indented on a separate line, with the colon or comma first on that line. [whitespace/indent] [4] Total errors found: 2 in 46 files If any of these errors are false positives, please file a bug against check-webkit-style.
Build Bot
Comment 37
2016-04-05 16:22:47 PDT
Comment on
attachment 275703
[details]
Fixing stream-response.html
Attachment 275703
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.webkit.org/results/1105872
New failing tests: imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-4.html
Build Bot
Comment 38
2016-04-05 16:22:53 PDT
Created
attachment 275712
[details]
Archive of layout-test-results from ews104 for mac-yosemite-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-yosemite-wk2 Platform: Mac OS X 10.10.5
Build Bot
Comment 39
2016-04-05 16:26:46 PDT
Comment on
attachment 275703
[details]
Fixing stream-response.html
Attachment 275703
[details]
did not pass ios-sim-ews (ios-simulator-wk2): Output:
http://webkit-queues.webkit.org/results/1105867
New failing tests: imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-4.html
Build Bot
Comment 40
2016-04-05 16:26:52 PDT
Created
attachment 275713
[details]
Archive of layout-test-results from ews121 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews121 Port: ios-simulator-wk2 Platform: Mac OS X 10.10.5
youenn fablet
Comment 41
2016-04-06 02:40:38 PDT
Created
attachment 275765
[details]
Trying to fix response-stream-disturbed-4.html
WebKit Commit Bot
Comment 42
2016-04-06 02:43:02 PDT
Attachment 275765
[details]
did not pass style-queue: ERROR: Source/WebCore/Modules/fetch/FetchResponseSource.h:41: Should be indented on a separate line, with the colon or comma first on that line. [whitespace/indent] [4] ERROR: Source/WebCore/bindings/js/ReadableStreamController.h:45: Should be indented on a separate line, with the colon or comma first on that line. [whitespace/indent] [4] Total errors found: 2 in 46 files If any of these errors are false positives, please file a bug against check-webkit-style.
Xabier Rodríguez Calvar
Comment 43
2016-04-06 02:55:08 PDT
Comment on
attachment 275765
[details]
Trying to fix response-stream-disturbed-4.html Considering that Fetch will need the Source and the ReadableStreamController, it might make more sense to split this patch into at least two, one for the RS and the other for Fetch code. Said this, I also think there were some changes in the spec lately that would be interesting to have a look at, just in case we are doing things that changed already, etc.
youenn fablet
Comment 44
2016-04-06 06:19:54 PDT
Created
attachment 275772
[details]
Patch
WebKit Commit Bot
Comment 45
2016-04-06 06:21:59 PDT
Attachment 275772
[details]
did not pass style-queue: ERROR: Source/WebCore/bindings/js/ReadableStreamController.h:45: Should be indented on a separate line, with the colon or comma first on that line. [whitespace/indent] [4] Total errors found: 1 in 47 files If any of these errors are false positives, please file a bug against check-webkit-style.
Eric Carlson
Comment 46
2016-04-06 08:47:04 PDT
Comment on
attachment 275772
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=275772&action=review
> Source/WebCore/ChangeLog:11 > + A createReadableStream function is introduced to allow DOM classes createa ReadableStream.
Nit: typo "createa"
> Source/WebCore/Modules/fetch/FetchBody.cpp:159 > + source.enqueue(ArrayBuffer::tryCreate(data.data(), data.size()));
Should this have a FIXME like that in BodyLoader::didReceiveData about what to do if ArrayBuffer::tryCreate returns null?
> Source/WebCore/Modules/fetch/FetchBodyOwner.cpp:209 > + m_readableStreamSource->enqueue(ArrayBuffer::tryCreate(data, size));
Ditto.
youenn fablet
Comment 47
2016-04-08 01:26:21 PDT
Comment on
attachment 275772
[details]
Patch Thanks for the feedback.
>> Source/WebCore/Modules/fetch/FetchBody.cpp:159 >> + source.enqueue(ArrayBuffer::tryCreate(data.data(), data.size())); > > Should this have a FIXME like that in BodyLoader::didReceiveData about what to do if ArrayBuffer::tryCreate returns null?
Yes, in that case, the stream will get errored and calling stream.close() afterwards will raise an exception. Either we should check it here or handle this at FetchResponseSource::close level. I will add a FIXME. The annoying thing is that I do not know how to write a test for this code path.
>> Source/WebCore/Modules/fetch/FetchBodyOwner.cpp:209 >> + m_readableStreamSource->enqueue(ArrayBuffer::tryCreate(data, size)); > > Ditto.
Right, we should add the same FIXME as for FetchResponse::BodyLoader::didReceiveData.
Alex Christensen
Comment 48
2016-04-08 13:58:33 PDT
Comment on
attachment 275772
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=275772&action=review
The code looks good and it makes many tests pass, which is good. I can't say I can wrap my head completely around the design of these objects, though.
> Source/WebCore/ChangeLog:8 > + This patch introduces ReadableStreamSource and ReadableStreamController which allow feeding a ReadableStream from DOM classes.
I'm not sure about this design. It might be great, but a quick check shows Chromium has no such classes. Could you describe why you went with this approach?
> Source/WebCore/Modules/fetch/FetchBody.cpp:164 > + case Type::Blob: > + owner.loadBlob(*m_blob, FetchLoader::Type::Stream);
At least assert m_blob
> Source/WebCore/bindings/js/ReadableStreamController.cpp:70 > + JSC::ExecState& state = *globalObject()->globalExec();
This is a lot of unchecked pointer dereferencing.
youenn fablet
Comment 49
2016-04-10 06:07:10 PDT
ReadableStream needs a JS source object with some of start, pull and cancel methods. Parameter passed to start and pull is a controller which has enqueue/error/close methods to control the stream state. The controller (JSReadableStreamController) is a JS built-in object. To help calling enqueue/close/error JS methods from dom classes, it is convenient to add a wrapper. This is the purpose of ReadableStreamController. It can also be used to query some stream internals (locked, disturbed). To implement the source, using IDL seems like the easiest choice. Currently ReadableStreamSource can handle any type of sources. Since fetch is push type, we could make it less general and probably more simple: no pull method, cancel returning void (sync cancel). In that case, ReadableStreamPushSource could be introduced instead. For fetch, the start promise is never resolved. This disables any call to pull. This also allows to enqueue/close/error at anytime. FetchResponse is marked as pending activity when stream is started until the stream gets closed, errored or canceled. I am not sure about chromium, I haven't checked its status lately. At some point streams were Dom/c++ based and thus directly tied to fetch. I think there were discussions to go to JS built-in but cannot say more than that.
youenn fablet
Comment 50
2016-04-17 09:37:44 PDT
Created
attachment 276592
[details]
After review
WebKit Commit Bot
Comment 51
2016-04-17 09:40:44 PDT
Attachment 276592
[details]
did not pass style-queue: ERROR: Source/WebCore/bindings/js/ReadableStreamController.h:45: Should be indented on a separate line, with the colon or comma first on that line. [whitespace/indent] [4] Total errors found: 1 in 47 files If any of these errors are false positives, please file a bug against check-webkit-style.
youenn fablet
Comment 52
2016-04-17 09:41:33 PDT
(In reply to
comment #50
)
> Created
attachment 276592
[details]
> After review
After thinking more about it, I removed the pull method from ReadableStreamSource since it is never called by FetchResponse. I also made cancel returning void since it is cancelled synchronously.
WebKit Commit Bot
Comment 53
2016-04-17 11:04:07 PDT
Comment on
attachment 276592
[details]
After review Clearing flags on attachment: 276592 Committed
r199641
: <
http://trac.webkit.org/changeset/199641
>
WebKit Commit Bot
Comment 54
2016-04-17 11:04:16 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.
Top of Page
Format For Printing
XML
Clone This Bug