[whatwg/streams] Fix assertion failure in RespondInternal after transferring array buffer in RespondWithNewView (#1174)

While implementing https://github.com/whatwg/streams/pull/1123 in Chrome, I realised that calling `RespondInternal(controller, view.[[viewByteLength]]` after calling `TransferArrayBuffer(view.[[ViewedArrayBuffer]])` makes the assertion in RespondInternal(), specifically `Assert: bytesWritten > 0`, fail. This is because `view.[[viewByteLength]]` becomes 0 after transferring the array buffer. 

This can either be solved by not using `TransferArrayBuffer()` (which was the case before) or by storing the `view.[[viewByteLength]]` first before transferring the buffer. In this PR, I've taken the latter approach.

@MattiasBuelens I'm wondering if you have any context on why we changed the standard to use `TransferArrayBuffer()` in `RespondWithNewView()`?
You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/streams/pull/1174

-- Commit Summary --

  * <a href="https://github.com/whatwg/streams/pull/1174/commits/5f36ddac096d9496677ca2f6f04cb85d26fcd143">Merge pull request #1 from whatwg/master</a>
  * <a href="https://github.com/whatwg/streams/pull/1174/commits/b5dbc0ec38c00ee73010222a413be2bb787444b1">Merge pull request #2 from whatwg/master</a>
  * <a href="https://github.com/whatwg/streams/pull/1174/commits/f423409fe4995bbbb460e023b6d3643dab98065a">Merge pull request #3 from whatwg/master</a>
  * <a href="https://github.com/whatwg/streams/pull/1174/commits/631447baf99a457ea399cdf6d8aeb43df7884299">Merge remote-tracking branch &#39;upstream/master&#39;</a>
  * <a href="https://github.com/whatwg/streams/pull/1174/commits/72e8f570276ffd44604f43d567c863ba7e5fd745">Merge remote-tracking branch &#39;upstream/master&#39;</a>
  * <a href="https://github.com/whatwg/streams/pull/1174/commits/7c80a45edd806db4c7116cb6623b6916db949b26">Merge branch &#39;whatwg:main&#39; into master</a>
  * <a href="https://github.com/whatwg/streams/pull/1174/commits/e1cfefe99ee864a0c48da4e14b933f41fc6a454d">Merge branch &#39;whatwg:main&#39; into master</a>
  * <a href="https://github.com/whatwg/streams/pull/1174/commits/8ed62f7bfe061dbfc78e2a7708f25b78e760a9ba">Merge branch &#39;whatwg:main&#39; into master</a>
  * <a href="https://github.com/whatwg/streams/pull/1174/commits/e527b34d1b5a44adc6e86598da004ee8dac4308c">store view byte length before transferring</a>

-- File Changes --

    M index.bs (3)

-- Patch Links --

https://github.com/whatwg/streams/pull/1174.patch
https://github.com/whatwg/streams/pull/1174.diff

-- 
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/streams/pull/1174

Received on Tuesday, 12 October 2021 07:08:55 UTC