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

Arrays with length larger than 196603 cause Malformed JS Call error #994

Closed
krystofwoldrich opened this issue Mar 2, 2023 · 9 comments
Closed

Comments

@krystofwoldrich
Copy link

krystofwoldrich commented Mar 2, 2023

Description

Imagine a native module with one function test that has one parameter -> array.

When you call it with an array that has more than 196603 items in it the array disappears.

And RN Bridge throws this error:

Error: Exception in HostFunction: Malformed calls from JS: field sizes are different.

[[42,81],[7,0],[[142,100,1673548954018,false]],354]

The array is an array of bytes in our case.

Question

Is this a bridge limitation?

On Android, with the New Architecture it works. (On iOS I got the same error.)

Files libraries are solving this by using strings

But we are concerned about the encoding overhead.

React Native Version

0.71.3

Output of npx react-native info

info Fetching system and libraries information...
System:
OS: macOS 13.2
CPU: (10) arm64 Apple M1 Pro
Memory: 148.30 MB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.19.0 - ~/.volta/tools/image/node/16.19.0/bin/node
Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
npm: 8.19.3 - ~/.volta/tools/image/node/16.19.0/bin/npm
Watchman: 2023.01.30.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /Users/krystofwoldrich/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
Android SDK:
API Levels: 28, 29, 30, 31, 32, 33
Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 33.0.0, 33.0.1
System Images: android-33 | Google APIs ARM 64 v8a
Android NDK: 22.1.7171670
IDEs:
Android Studio: 2021.3 AI-213.7172.25.2113.9123335
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
Languages:
Java: 17.0.5 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.3 => 0.71.3
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

  1. Create a native module with a function test(array)
  2. Call this function with an array that has more than 196603 items.

I've tested this with numbers and objects and got the same error.

Also tried to enclose the array into an object and got the same error.

Snack, code example, screenshot, or link to a repository

Original issue at @sentry/react-native:

@github-actions
Copy link

github-actions bot commented Mar 2, 2023

⚠️ Newer Version of React Native is Available!
ℹ️ You are on a supported minor version, but it looks like there's a newer patch available. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@krystofwoldrich
Copy link
Author

krystofwoldrich commented Mar 7, 2023

I've tried this with JSC and it works. The problem seems to be only with Hermes in the dev environment.

@krystofwoldrich
Copy link
Author

Was anyone tracked down what causes the issue?

@cortinico cortinico transferred this issue from facebook/react-native May 15, 2023
@tmikov
Copy link
Contributor

tmikov commented May 15, 2023

This doesn't look like a Hermes bug, or if it is, can we please get a minimal repro? The error in the description is not generated by Hermes. The number 196603 seems to be related to the maximum number of properties that a Hermes object can hold (196607), so more than likely this is a case of using an object instead of an array somewhere.

@krystofwoldrich
Copy link
Author

@tmikov There is a repro here, but I can add it to https://github.com/react-native-community/reproducer-react-native to make it easier to work with.

@tmikov
Copy link
Contributor

tmikov commented Jun 16, 2023

@krystofwoldrich I am sorry, by a minimal repro we mean a small snippet of code (a few lines), without any dependencies, without React Native, demonstrating the problem.

Hermes is just the JavaScript VM. It is not practical for us to debug RN apps or 3rd party libraries in order to identify VM bugs.

As I mentioned before, judging by the information provided, this does not look like a Hermes bug. If you believe it is a Hermes bug, please try to narrow it down to just a few lines of pure JS code demonstrating the problem and we will take it from there.

@krystofwoldrich
Copy link
Author

@tmikov Thank you for the explanation. I'll try to dig a bit deeper to see where the issue is coming from.

@colafati
Copy link

I have the same issue while using lz-string on a 2MB string. After updating the Hermes version, my App does not work anymore.

@tmikov
Copy link
Contributor

tmikov commented Dec 23, 2023

Closing, but please feel free to reopen with a minimal repro.

@tmikov tmikov closed this as not planned Won't fix, can't repro, duplicate, stale Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants