react-nativebluetooth-lowenergycommunication

Malformed calls from JS : field sizes are different


I've gone through link : https://github.com/facebook/react-native/issues/23835#issuecomment-493007479

But got no solution. I got the understanding that this bug is triggered when

  1. You send NaN in array on react native bridge. I don't know much about it.
  2. During use of invalid data (infinity) in animation.
  3. During bottom navigation.
  4. Using menu.
  5. Showing response data in Alert or Notifications as Toasts.

I am using react-native-ble-manager.

Procedure: I sent write message using characteristic that allows write, after setting notifications on for characteristic that allows read. I got 'ack' in the response listener that was used to receive notifications, and then I start sending custom data chunks by chunks as designed.

I get this error during this first chunk was being sent.

I've checked my uint8Array for any wrong data using iteration and to, but couldn't found any.

From my logs:

2020-09-04 12:52:13.944 21942-22004/com.my_app E/ReactNativeJS: Error: Exception in HostFunction: Malformed calls from JS: field sizes are different.
    
    [[3,13,37],[5,22,0],[["{\"type\":\"log\",\"level\":\"log\",\"data\":[\"payload[18]: \\u0000\"]}",1],[221,100,1599204133919,false]],2453]

Solution

  • I iterated through my uint8Array and took each of the elements in var newArr = [];

    I also did newArr[i] = newArr[i] & 0xff.

    This means each element should confirm to uint8, by having same size. This method does it. Unwanted overflow is removed while actual data is maintained.

    The error was gone.