Arrays with length larger than 196603 cause `Malformed JS Call` error
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.
- https://github.com/itinance/react-native-fs/blob/master/FS.common.js?rgh-link-date=2023-03-02T09%3A54%3A24Z#L396
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
- https://github.com/krystofwoldrich/repro-large-array
- Create a native module with a function
test(array) - 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:
- https://github.com/getsentry/sentry-react-native/issues/2744