Bug 184886 - WebAssembly: add support for stream APIs - JavaScript API: Implement loading for the Blob type
Summary: WebAssembly: add support for stream APIs - JavaScript API: Implement loading ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on: 183442
Blocks: 161709
  Show dependency treegraph
 
Reported: 2018-04-23 09:34 PDT by GSkachkov
Modified: 2021-02-02 13:45 PST (History)
16 users (show)

See Also:


Attachments
Patch (7.68 KB, patch)
2021-02-02 00:21 PST, Yusuke Suzuki
youennf: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description GSkachkov 2018-04-23 09:34:26 PDT
Implement loading for the Blob type for streaming API, currently implemented SharedBuffer
Comment 1 JF Bastien 2018-04-23 09:38:59 PDT
You mean this: https://developer.mozilla.org/en-US/docs/Web/API/Blob ?
Comment 2 GSkachkov 2018-04-23 09:49:22 PDT
(In reply to JF Bastien from comment #1)
> You mean this: https://developer.mozilla.org/en-US/docs/Web/API/Blob ?

Yeah, this currently fails:
```
const blob = new Blob(...);
WebAssembly.instantiateStreaming(new Response(blob, { headers: { "Content-Type" : "application/wasm" }}));
```

currently my patch support only Responses manually created from  ReadableStream:
```
const stream = new ReadableStream(...);
WebAssembly.instantiateStreaming(new Response(stream, { headers: { "Content-Type" : "application/wasm" }}));
```
Comment 4 Yusuke Suzuki 2021-01-25 14:02:41 PST
Will do at the same time.

*** This bug has been marked as a duplicate of bug 173105 ***
Comment 5 Yusuke Suzuki 2021-01-26 23:10:35 PST
Initially, we do not support it.
Comment 6 Yusuke Suzuki 2021-02-01 02:06:55 PST
@Youenn Would you mind telling me the best way to load bytes from FormData? FetchResponse can have FormData as its body, and we would like to load byte streams from that to pass this data to Wasm streaming compiler.
Comment 7 Yusuke Suzuki 2021-02-02 00:21:37 PST
Created attachment 418968 [details]
Patch
Comment 8 EWS Watchlist 2021-02-02 00:22:23 PST
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 9 youenn fablet 2021-02-02 01:28:01 PST
Comment on attachment 418968 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=418968&action=review

> Source/WebCore/bindings/js/JSDOMGlobalObject.cpp:349
> +    }

Sounds good like this.
Or maybe we could introduce a utility method that would handle blob through consumeBodyReceivedByChunk, since the same thing is used in DOMCache.

> LayoutTests/imported/w3c/web-platform-tests/wasm/wasm_stream_instantiate_test.html:113
> +  }, "instantiateStreaming using blob");

Might be worth adding a test with form data even though we fail it for now?
Comment 10 Yusuke Suzuki 2021-02-02 10:27:39 PST
Comment on attachment 418968 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=418968&action=review

>> Source/WebCore/bindings/js/JSDOMGlobalObject.cpp:349
>> +    }
> 
> Sounds good like this.
> Or maybe we could introduce a utility method that would handle blob through consumeBodyReceivedByChunk, since the same thing is used in DOMCache.

For now, I want to have this separate from consumeBodyReceivedByChunk (first, making it ReadableStream, and then use it in consumeBodyReceivedByChunk), because creating ReadableStream can cause exception.
And we need JSGlobalObject, while the other ones are not requiring it in consumeBodyReceivedByChunk.
I think, possibly, in the future change, we could just call consumeBodyReceivedByChunk without making Blob to ReadableStream (using BlobLoader).

>> LayoutTests/imported/w3c/web-platform-tests/wasm/wasm_stream_instantiate_test.html:113
>> +  }, "instantiateStreaming using blob");
> 
> Might be worth adding a test with form data even though we fail it for now?

Sounds good! Added.
Comment 11 Yusuke Suzuki 2021-02-02 10:30:50 PST
Committed r272221: <https://trac.webkit.org/changeset/272221>
Comment 12 Radar WebKit Bug Importer 2021-02-02 10:35:23 PST
<rdar://problem/73886641>
Comment 14 Yusuke Suzuki 2021-02-02 13:45:42 PST
(In reply to Aakash Jain from comment #13)
> (In reply to Yusuke Suzuki from comment #11)
> > Committed r272221: <https://trac.webkit.org/changeset/272221>
> This seems to have broken two layout tests:
> https://results.webkit.org/?suite=layout-tests&suite=layout-
> tests&test=imported%2Fw3c%2Fweb-platform-
> tests%2Fwasm%2Fwasm_stream_instantiate_test.html&test=imported%2Fw3c%2Fweb-
> platform-tests%2Fwasm%2Fwasm_stream_instantiate_test.html

Fixed in https://bugs.webkit.org/show_bug.cgi?id=221281