Skip to content

[Feature Request] Migrate to JSI for React Native #16031

@jhen0409

Description

@jhen0409

Describe the feature request

react_native binding

Migrate to JSI can help to improve performance issues with the current implementation of React Native bridge and base64 encode/decode.

For return type of tensor input and output, we can construct ArrayBuffers from existing memory buffers, but it may be only supported by newer React Native version (>= 0.71?). Another way is implement type like blob-jsi-helper does with memcpy but it may causes some memory issues.

I might try to send a PR later for iOS first.

For Android, since it's using C++, it may require some additional work to access onnxruntime directly. (Calling java class through JNI may become complicated)

Describe scenario use case

Transformers.js is trying to support React Native (huggingface/transformers.js#118 by @hans00), I found that the performance in base64 encode/decode of buffer is not so good. See also this comment.

I also try to use react-native-blob-jsi-helper to replace base64 by a patch for test purpose, see this draft PR for more details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api:Javaissues related to the Java APIfeature requestrequest for unsupported feature or enhancementplatform:mobileissues related to ONNX Runtime mobile; typically submitted using template

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions