Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blob constructor is not spec compliant #44125

Open
shamilovtim opened this issue Apr 16, 2024 · 3 comments
Open

Blob constructor is not spec compliant #44125

shamilovtim opened this issue Apr 16, 2024 · 3 comments
Labels
Needs: Attention Issues where the author has responded to feedback. Needs: Triage 🔍 Never gets stale Prevent those issues and PRs from getting stale

Comments

@shamilovtim
Copy link
Contributor

shamilovtim commented Apr 16, 2024

Description

The constructor for React Native's Blob has a comment:

"Currently we only support creating Blobs from other Blobs."

BlobManager confirms this:

"Creating blobs from 'ArrayBuffer' and 'ArrayBufferView' are not supported"

This API is not spec compliant, since this is what the Blob specification specifies:

(Constructed from) "An iterable object such as an Array, having ArrayBuffers, TypedArrays, DataViews, Blobs, strings, or a mix of any of such elements, that will be put inside the Blob. Strings should be well-formed Unicode, and lone surrogates are sanitized using the same algorithm as String.prototype.toWellFormed()."

Steps to reproduce

  1. Try to call:
new Blob(new Uint8Array([
    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
    21, 22, 23,
  ]);

See that RN doesn't support Blobs composed of anything but Blobs or strings.

React Native Version

0.73.6

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx react-native info

N/A

Stacktrace or Logs

N/A

Reproducer

N/A

Screenshots and Videos

No response

@github-actions github-actions bot added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Apr 16, 2024
Copy link

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

@cortinico cortinico added Never gets stale Prevent those issues and PRs from getting stale and removed Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Apr 17, 2024
@huzhanbo1996
Copy link

huzhanbo1996 commented May 13, 2024

Hi @shamilovtim, I'm looking into this. Blob on RN is String based and does not provide any stream/binary API. Could you describe your usage/need? So we can find out what else we should do to make Blob more usable.

@shamilovtim
Copy link
Contributor Author

Hi @huzhanbo1996

The problem is that everyone on web builds on the Blob specification which is available on other platforms and browsers but RN's Blob does not meet these specifications. Then when libraries are used in RN they break because they rely on broken / incomplete Blob.

To describe what I need

  1. I need to be able to construct a Blob from TypedArrays or ArrayBuffers like the Blob specification allows for. Because this is missing from RN Blob, certain web libraries break when used on react native.

Blob on RN is String based and does not provide any stream/binary API

  1. Yes this is also a separate problem. I need to be able to call stream() on Blob as well, and this is another case where RN Blob does not match web specs.

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Attention Issues where the author has responded to feedback. Needs: Triage 🔍 Never gets stale Prevent those issues and PRs from getting stale
Projects
None yet
Development

No branches or pull requests

3 participants