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

Native @ReactMethod promise asking a Callback will bug/crash #29416

Closed
FayDoom opened this issue Jul 18, 2020 · 3 comments
Closed

Native @ReactMethod promise asking a Callback will bug/crash #29416

FayDoom opened this issue Jul 18, 2020 · 3 comments
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@FayDoom
Copy link

FayDoom commented Jul 18, 2020

Description

If a Java @ReactMethod ask for a Callback and a Promise, React native will throw :

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

If Hermes is enabled, the app will just crash with :

"A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL)"

React Native version:

I tried on 0.63.0 and 0.63.1. Same issue.

Steps To Reproduce

  1. Init a new RN project
  2. Create a Java module with a method asking a Callback and a Promise :
    @ReactMethod public void jCall(Callback cb, Promise p){ ... }
  3. Call it from Javascript
    await _javaModule.jCall((e)=>{ ... })

Expected Results

The method should be called, passing the react.bridge.Callback and implicitly a react.bridge.Promise to the Java side and not crash.

Edit

After a few more tests (all with Hermes enabled), there are my results :

  • When two Callback are required, everything works.
    @ReactMethod public void jCall(Callback res, Callback rej){ ... }
    await _javaModule.jCall((e)=>{ ... }, (e)=>{ ... })

  • When three Callback are required, It doesn't crash this time but throw an error.
    @ReactMethod public void jCall(Callback cb, Callback res, Callback rej){ ... }
    await _javaModule.jCall((e)=>{ ... }, (e)=>{ ... }, (e)=>{ ... })
    Throw : Malformed calls from JS: field sizes are different

  • It seems that we can't invoke multiple distincts callbacks. Which explain some of my results. Is it meant to be that way ? If so, the official documentation isn't clear.

@SudoPlz
Copy link
Contributor

SudoPlz commented Apr 14, 2021

I just posted a long answer here about what's happening and how to troubleshoot that: https://stackoverflow.com/a/67100389/1658268

@github-actions
Copy link

github-actions bot commented Jun 6, 2023

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jun 6, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

2 participants