Closed Bug 1752662 Opened 2 years ago Closed 2 years ago

WPT streams/readable-byte-streams/tee.any.js - TypeError: Pending PullInto has detached buffer

Categories

(Core :: DOM: Streams, defect, P1)

defect

Tracking

()

RESOLVED FIXED
99 Branch
Tracking Status
firefox99 --- fixed

People

(Reporter: saschanaz, Assigned: saschanaz)

References

Details

Attachments

(1 file)

"ReadableStream teeing with byte source: read from branch2, then read from branch1" test times out and throws an error somehow to the global without rejecting any promise.

Per https://wpt.fyi/results/streams/readable-byte-streams/tee.any.js?label=experimental&label=master&aligned no browser is passing the test, so I wonder who's the culprit here - the test or our impl?

Chrome doesn't implement ReadableByteStreamTee, so they use ReadableStreamDefaultTee for everything. In theory there is a reference implementation in JS, I would hope that it passes all tests, but I've never tried it.

Blocks: 1751015
No longer blocks: 1730584

The CI on the spec repo makes sure that the reference implementation passes every test, so it should be us. 👀 (Or maybe the spec, who knows)

Taking a look... but feel free to add some comment if you already have an idea what's going on.

Assignee: nobody → krosylight

Still investigating... What I understand so far is that the buffer of the PullIntoDescriptor made by ReadableByteStreamControllerPullInto (from reader2.read()) is transferred to another PullIntoDescriptor made during ByteStreamTeePullAlgorithm, and that causes a problem:

[0x0]   xul!mozilla::dom::TransferArrayBuffer   
[0x1]   xul!mozilla::dom::ReadableByteStreamControllerPullInto + 0x1d8   
[0x2]   xul!mozilla::dom::ReadableStreamBYOBReaderRead + 0x18c   
[0x3]   xul!mozilla::dom::PullWithBYOBReader + 0x261   
[0x4]   xul!mozilla::dom::ByteStreamTeePullAlgorithm + 0x1a6   
[0x5]   xul!mozilla::dom::NativeByteStreamTeePullAlgorithm::PullCallback + 0x111   
[0x6]   xul!mozilla::dom::ReadableByteStreamControllerCallPullIfNeeded + 0x12d   
[0x7]   xul!mozilla::dom::ReadableByteStreamControllerPullInto + 0xb01   

Specifically this line passes the view: https://searchfox.org/mozilla-central/rev/4615b544a0f7166233c409c619b426c4025467a7/dom/streams/ReadableStreamTee.cpp#270

Nice work pin pointing this line! The fixes is to simply pass the correct argument for aForBranch2.

-    PullWithBYOBReader(aCx, aTeeState, view, false, aRv);
+    PullWithBYOBReader(aCx, aTeeState, view, /* aForBranch2 */ index == 2, aRv);

I think Matthew suggested using an enum index before and this just underlines that.

OMG C++ 😭

Pushed by krosylight@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/fd7d69e519d9
Use enum class TeeBranch instead of boolean/integer r=evilpie
Severity: -- → S3
Priority: -- → P1
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 99 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: