Closed Bug 1659025 Opened 4 years ago Closed 2 years ago

Implement transferable streams

Categories

(Core :: DOM: Streams, enhancement, P3)

79 Branch
enhancement

Tracking

()

RESOLVED FIXED
102 Branch
Tracking Status
firefox102 --- fixed

People

(Reporter: ricea, Assigned: saschanaz)

References

(Blocks 1 open bug)

Details

(Keywords: dev-doc-complete)

Attachments

(3 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36

Steps to reproduce:

const rs = new ReadableStream();
window.postMessage(rs, '*', [rs]);

Actual results:

A "The object could not be cloned." DOMException is thrown because transferable streams are not implemented.

Expected results:

The window onmessage event should fire with the transferred stream as data, and the original stream should be locked.

See https://github.com/whatwg/streams/pull/1053 for the spec change and https://github.com/web-platform-tests/wpt/pull/24546 for the web platform tests.

Severity: -- → N/A
Priority: -- → P3

Mozilla needs to evaluate and declare an official position on this feature as a first step.

See: https://github.com/mozilla/standards-positions/issues/430

Component: DOM: Core & HTML → DOM: Streams

Anne, per comment #1, do you think there's any blocker?

Flags: needinfo?(annevk)
Blocks: dom-streams

I think we should support this. I had missed the standards-positions issue. Replied there just now.

Flags: needinfo?(annevk)
No longer blocks: dom-streams
Assignee: nobody → krosylight
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

Regarding [Transferable] support, although it's not a blocker:

See Also: → 1562065

Let promise be ! ReadableStreamPipeTo(value, writable, false, false, false).

A reference for the future: https://searchfox.org/mozilla-central/rev/8e1eb5cbd89a2455c34032d921f8de28261d016b/dom/base/StructuredCloneHolder.cpp#1254

Depends on: 1734241
Depends on: 1757808

PackAndPostMessageHandlingError used in the transfer steps wants to clone DOMException.

Depends on: 1561357

transferable/window.html fails with weird behavior. The last iframe test timeouts, but if I add breakpoints before two read() calls in testTransferredReadableStream() in resources/helpers.js then it succeeds. I'm not sure why and how it matters here.

I believe the same issue affects several other tests too. AFAICT it only happens in cross-context situation 🤔

Edit: It was some event loop issue, still investigating...
Edit 2: It was not. It was a never-settled promise logic issue.

Attachment #9265238 - Attachment description: WIP: Bug 1659025 - Implement [Transferable] for ReadableStream → Bug 1659025 - Implement [Transferable] for ReadableStream r=mgaudet!,smaug!
Attachment #9265238 - Attachment description: Bug 1659025 - Implement [Transferable] for ReadableStream r=mgaudet!,smaug! → Bug 1659025 - Implement [Transferable] for ReadableStream r=smaug!,sfink!
Depends on: 1766260

There is no guarantee for message events to always preceed delay(0).

Depends on D139525

See Also: → 1769518
Blocks: 1730584
No longer depends on: 1730584
Pushed by krosylight@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/180af79082fb
Implement [Transferable] for ReadableStream r=smaug,sfink
https://hg.mozilla.org/integration/autoland/rev/cc94267daae1
Fix tests using delay(0) r=smaug
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/34105 for changes under testing/web-platform/tests

Backed out for causing build bustages on Unified_cpp_netwerk_ipc0.obj

Flags: needinfo?(krosylight)
Upstream PR was closed without merging
Pushed by krosylight@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a7f050ab968d
Implement [Transferable] for ReadableStream r=smaug,sfink
https://hg.mozilla.org/integration/autoland/rev/9442f1d617ea
Fix tests using delay(0) r=smaug
Flags: needinfo?(krosylight)

Backed out for causing wpt failures

Backout link: https://hg.mozilla.org/integration/autoland/rev/45cec5a178e5361a9b14cca089eef1be2730aafd

Push with failures: https://treeherder.mozilla.org/jobs?repo=autoland&resultStatus=testfailed%2Cbusted%2Cexception%2Cretry%2Cusercancel&revision=9442f1d617ea843cad31089022fd806da6553c20&selectedTaskRun=C_YzXriATHCTNUQcJ27ALg.0

Link to failure log:
https://treeherder.mozilla.org/logviewer?job_id=378497677&repo=autoland&lineNumber=4020
https://treeherder.mozilla.org/logviewer?job_id=378499565&repo=autoland&lineNumber=4034
https://treeherder.mozilla.org/logviewer?job_id=378499530&repo=autoland&lineNumber=5865

Failure line:
TEST-UNEXPECTED-FAIL | /streams/transferable/transform-stream.html | piping through transferred transforms should work - assert_equals: transforms should have been applied expected "HELLO HELLO THERE THERE " but got "HELLO HELLO "
TEST-UNEXPECTED-FAIL | /streams/transferable/writable-stream.html | second write should wait for first underlying write to complete - promise_test: Unhandled rejection with value: object "TypeError: resolveWrite is not a function"
TEST-UNEXPECTED-FAIL | /streams/transferable/writable-stream.html | second write should wait for first underlying write to complete - assert_true: second write should have resolved expected true got false

Flags: needinfo?(krosylight)
Upstream PR was closed without merging
Attachment #9265238 - Attachment description: Bug 1659025 - Implement [Transferable] for ReadableStream r=smaug!,sfink! → Bug 1659025 - Implement [Transferable] for ReadableStream r=smaug
Pushed by krosylight@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/6c2ff5402279
Implement [Transferable] for ReadableStream r=smaug,sfink
https://hg.mozilla.org/integration/autoland/rev/848b3025ef7c
Fix tests using delay(0) r=smaug
https://hg.mozilla.org/integration/autoland/rev/454e9dcf4419
Add `dom.streams.transferable.enabled` r=smaug
Keywords: dev-doc-needed
Regressions: 1770172
Flags: needinfo?(krosylight)
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 102 Branch
Upstream PR merged by moz-wptsync-bot
Blocks: 1770627

FYI, docs work for this can be tracked in https://github.com/mdn/content/issues/16930#issuecomment-1145616374

The work was mostly just adding an entry to browser compatibility data for the three stream interfaces and an entry to the experimental features page.

Regressions: 1818576
Regressions: 1818655
Regressions: 1830190
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: