Closed Bug 1777413 Opened 3 months ago Closed 3 months ago

External array buffers can't be zero-length

Categories

(Core :: JavaScript: Standard Library, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
104 Branch
Tracking Status
firefox104 --- fixed

People

(Reporter: jimb, Assigned: jimb, NeedInfo)

References

Details

Attachments

(1 file, 1 obsolete file)

At the moment, JS::NewExternalArrayBuffer requires that the nbytes argument be greater than zero. However, WebGPU uses external ArrayBuffers to give content access to GPU buffer contents, and WebGPU buffer ranges may be zero bytes long. SpiderMonkey's restriction makes its external ArrayBuffers impossible to use for WebGPU.

From looking at the code, I can't see any reason for this restriction. Ordinary JS ArrayBuffers can certainly be zero bytes long.

We need to fix this to resolve WebGPU bug 1771507.

Assignee: nobody → jimb
Blocks: 1771507
Pushed by jblandy@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/bd61ede3832f
Permit zero-length external ArrayBuffers. r=tcampbell
Pushed by csabou@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/25491dd621c2
Backed out changeset bd61ede3832f for causing SM bustages.
https://hg.mozilla.org/integration/autoland/rev/a3e646ff4b21
Permit zero-length external ArrayBuffers. r=tcampbell
Attachment #9283724 - Attachment description: WIP: Bug 1777413: Remove redundant assertion that a size_t >= 0. → Bug 1777413: Remove redundant assertion that a size_t >= 0.
Attachment #9283724 - Attachment is obsolete: true
Attachment #9283570 - Attachment description: Bug 1777413: Permit zero-length external ArrayBuffers. r?tcampbell → Bug 1777413: Permit zero-length external ArrayBuffers. r=tcampbell

Unfortunately, I missed a few details in D150701:

  1. Since nbytes is size_t, comparing nbytes >= 0 is trivially true, so the assertion should just be deleted altogether.

  2. The new test needs a skip-if(!xulRuntime.shell) condition.

Pushed by jblandy@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/90c1ee100fc1
Permit zero-length external ArrayBuffers. r=tcampbell
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 104 Branch
You need to log in before you can comment on or make changes to this bug.