react-native-community / discussions-and-proposals

Discussions and proposal related to the main React Native project

Home Page:https://facebook.github.io/react-native/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ArrayBuffer over RN Bridge

EternalDeiwos opened this issue · comments

Introduction

There has been discussion on the main repo (facebook/react-native#1424) about the use of ArrayBuffers over the React Native Bridge -- specifically around the use of websockets. This issue was resolved and we are now supposedly able to receive websocket message and fetch response bodies as ArrayBuffers (I haven't done this myself but I've seen a bunch of things suggesting that it works). Would it be possible to extend these specific cases to support ArrayBuffers as a first class data type for the RN Bridge?

The Core of It

Those of us who are attempting to use native features for communication and cryptographic operations (among many others) would benefit from being able to pass data through the bridge. In particular, this would ease access to device hardware such as the Android KeyStore / iOS Secure Enclave, NFC, etc.

Current Solutions

Currently I'm just base64 encoding my ArrayBuffers and passing them through the bridge as a string.

Discussion

  • How are you currently getting around this (if not the same as the above)?
  • Are there things you'd like to do that do not have a work-around?
  • What would be involved in supporting this?

👋 there - as stated in the README and the issue template, this repo is for long-form discussions. Yours seems more a precise feature request, so I suggest you use Canny instead.

That said, two more things:

  1. with the current re-architecture of RN ongoing, the bridge will change significantly, so I think that you should check the dedicated discussions in this repo (probably TurboModules and JSI are the ones that may interest you most

  2. You should also take a look at this conversation #99 as I feel it overlaps a bit with what you are working with

Also, I believe TurboModules will provide exactly what you are looking for. JS and Native will be able to share references to objects and memory managed by native.

@TheSavior had TurboModules landed in RN yet?