WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
310373
TextDecoder fails occasionally, not each time.
https://bugs.webkit.org/show_bug.cgi?id=310373
Summary
TextDecoder fails occasionally, not each time.
Andrew Hodel
Reported
2026-03-20 10:39:57 PDT
Created
attachment 478734
[details]
error in console that shows value aaaa of ArrayBuffer and occasional failure The first parameter to `TextDecoder.decode` is as specified at
https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/decode
Parameters buffer Optional An ArrayBuffer, a TypedArray, or a DataView object containing the encoded text to decode. It is a `ArrayBuffer` with the utf8 value `aaaa` as shown in the screenshot. ``` 9052 unicode_string_from_ab_decode(ab) { 9053 9054 var r = Math.random(100); 9055 9056 console.log(r, ab instanceof Uint8Array, ab, new Uint8Array(ab)); 9057 9058 let decoder = new TextDecoder('utf-8'); 9059 let decoded_value = decoder.decode(ab); 9060 9061 console.log(r, ab instanceof Uint8Array, typeof(decoded_value)); 9062 9063 return decoded_value; 9064 9065 } ```
Attachments
error in console that shows value aaaa of ArrayBuffer and occasional failure
(465.14 KB, image/png)
2026-03-20 10:39 PDT
,
Andrew Hodel
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Andrew Hodel
Comment 1
2026-03-20 10:54:12 PDT
It works if you create another non resizable ArrayBuffer, thereby doubling the memory usage. From MDN Web Docs via Google Gemini: TextDecoder.decode() generally expects a fixed-length ArrayBuffer or a TypedArray. While newer JavaScript standards allow resizable ArrayBuffers, they can cause issues in older APIs. To fix this, create a new, non-resizable Uint8Array view or copy of the buffer content before passing it to TextDecoder.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug