Skip to content

Conversation

@MattiasBuelens
Copy link
Collaborator

@MattiasBuelens MattiasBuelens commented Aug 15, 2025

Previously, the reference implementation did not implement the TransferArrayBuffer abstract op correctly, because we didn't have a way of doing that synchronously in user-land code. Today, we can use ArrayBuffer.prototype.transfer() for that.

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

Comment on lines +1587 to +1588
const byteOffset = view.byteOffset;
const byteLength = view.byteLength;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reference implementation was doing steps 8 and 9 after calling TransferArrayBuffer, which meant that view.byteLength was already 0. We didn't notice this, because we weren't actually transferring before. 😛

Fortunately, all "real" implementations already do this correctly.

O[isFakeDetached] = true;

return transferredIshVersion;
return ArrayBufferPrototypeTransferToFixedLength.call(O);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using transferToFixedLength() since we don't (yet) support resizable ArrayBuffers.

I think we can loosen that restriction, but we should do that in an actual spec change. 😉

@MattiasBuelens MattiasBuelens force-pushed the ref-impl-arraybuffer-transfer branch from 852ded4 to 5cde2af Compare August 17, 2025 11:40
@MattiasBuelens MattiasBuelens requested a review from ricea August 17, 2025 11:45
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I guess you might want to roll in web-platform-tests/wpt#54350 before merging?

@MattiasBuelens
Copy link
Collaborator Author

Done, ready to land. 🛬

@domenic domenic merged commit ae5fbaa into whatwg:main Aug 19, 2025
3 checks passed
@MattiasBuelens MattiasBuelens deleted the ref-impl-arraybuffer-transfer branch August 19, 2025 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants