feat: read blob bytes directly in FileReader.readAsArrayBuffer - #58031
Open
paradowstack wants to merge 4 commits into
Open
feat: read blob bytes directly in FileReader.readAsArrayBuffer#58031paradowstack wants to merge 4 commits into
paradowstack wants to merge 4 commits into
Conversation
paradowstack
force-pushed
the
feat/filereader-read-as-array-buffer
branch
from
August 20, 2026 13:29
7ec3142 to
3e4bdb9
Compare
|
Warning JavaScript API change detected This PR commits an update to
This change was flagged as: |
paradowstack
force-pushed
the
feat/filereader-read-as-array-buffer
branch
3 times, most recently
from
August 20, 2026 14:07
ad5ade0 to
01ab62a
Compare
paradowstack
marked this pull request as ready for review
August 20, 2026 14:08
paradowstack
force-pushed
the
feat/filereader-read-as-array-buffer
branch
from
August 20, 2026 14:38
01ab62a to
93b9c18
Compare
paradowstack
force-pushed
the
feat/filereader-read-as-array-buffer
branch
from
August 21, 2026 06:40
93b9c18 to
146222c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebase Note:
This branch is stacked on #57937 (
Promise<ArrayBuffer>for Java/ObjC TurboModules) and #58029 (feat: support Array as a TurboModule method parameter) and #58030 (feat: accept ArrayBuffer and ArrayBufferView parts in Blob and File) and must be rebased ontomainonce that lands. For now review only the last commit.Summary:
FileReader.readAsArrayBuffer()was implemented on top ofreadAsDataURL: native base64-encoded the blob into a data URL, JS split the string and decoded it back to bytes withbase64-js. That is a base64 encode, a JS decode, and two full copies of the payload for every read.Native now returns the bytes directly.
BlobModule.resolveBuffer/-[RCTBlobManager resolveBuffer:offset:size:]copy the requested range into anArrayBuffer/RCTArrayBuffer, andreadAsArrayBufferresolves the Promise with it — zero-copy from there to JS. The single copy is required rather than incidental: the buffer is handed to JS zero-copy, and Blobs are immutable per the W3C File API, so JS must not be able to write through to blob storage.Rebase Note:
This branch is stacked on #57937 (
Promise<ArrayBuffer>for Java/ObjC TurboModules) and must be rebased ontomainonce that lands.Changelog:
[GENERAL] [ADDED] -
FileReader.readAsArrayBuffer()reads blob bytes directly instead of decoding a base64 data URLTest Plan:
FileReader-testcovers a successful read,TypeErroron a null blob, aborting a pending read, the stale-read guard when a newer read supersedes an in-flight one, and aNotReadableErrorDOMExceptionon rejection.FileReaderModuleTestcovers reading a whole blob, an offset/size range, an unknown blob id, a missing blob id, and that the resolved buffer does not alias blob storage.BlobModuleTest/RCTBlobManagerTestscoverresolveBufferfor whole and ranged reads, an unknown id, and that the returned buffer is an independent copy with a full0..capacitywindow.Blobexample that builds a blob perBlobPartvariant, reads each back throughreadAsArrayBuffer, and compares the bytes.