w3c / w3c/FileAPI

Correct handling of resizable ArrayBuffer?

Aperta
#219 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
HTML
Stelle
118
Fork
52
Merge medio
9g 16h
PR unite (30g)
1

Descrizione

Given const b = new Blob([A, B]), where A is a TypedArray with a resizable ArrayBuffer, what is the expected behavior?

Chrome/Firefox currently both throw an error if any of the source ArrayBuffer instances are resizable; other runtimes do not.

There is an issue here if A is resized while the Blob is being constructed and the data is being copied. This can happen, for instance, if B has a getter for it's length that causes A to be resized and the implementation uses a flow like...

let total = 0;
for (const chunk of chunks) {
  total += chunk.length;  // B could resize A as a side effect here
}
const dest = allocate(total);
for (const chunk of chunks) {
  copy chunk into dest
}

Let's suppose that A and B both initially have length 10, but B's length getter resizes A to 5... what should the result be?

  1. Length 15, with 5 bytes from A, 10 bytes from B, allocation gets trimmed at the end of the copy
  2. Length 20, with 5 bytes from A, 10 bytes from B, and 5 zeroed bytes at the end?
  3. Length 20, with 5 bytes from A, 5 zeroed bytes, 10 bytes from B
  4. Error thrown because length changed?
  5. Something else?

What if A is resized larger? Is the result just truncated?

Should the spec for Blob explicitly make Chrome/Firefox's behavior of throwing immediately on resizable ArrayBuffer's standard? etc.

/cc @guybedford

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

L’issue non indica file del repository né test. Inizia determinando il comportamento previsto per la costruzione di un Blob quando un TypedArray sorgente usa un resizable ArrayBuffer e le sue dimensioni cambiano durante la copia, quindi documenta il comportamento scelto e se la specifica debba richiedere un errore o un altro risultato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
web-dev
Tipo di issue
Bug
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Tranquilla
Chiarezza
Da chiarire
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.