Skip to content

JS call stack freezes after displayIncomingCall until user interaction #828

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

Open
dkornilove opened this issue Jan 29, 2025 · 0 comments
Open

Comments

@dkornilove
Copy link

Description

My app receives a silent push notification (voip) and processes it in headless mode with the help of firebase backgroundHandler.

import messaging from '@react-native-firebase/messaging';
messaging().setBackgroundMessageHandler(onReceiveMessageInBackground);

I use react-native-callkeep to invoke displayIncomingCall. The system dialer appears as expected, but on some android Xiaomi devices, JavaScript execution in headless mode seems to freeze until the user interacts with the phone (e.g., accepts/rejects the call or opens the app).

For example, if I subscribe to the didDisplayIncomingCall event and schedule a delayed function:

RNCallKeep.addEventListener('didDisplayIncomingCall', (data) => {  
  setTimeout(() => console.log('Boom!'), 5000);  
});

The setTimeout callback does not execute after 5 seconds. Instead, it only triggers when the user interacts with the phone, even if that happens 40+ seconds later.

This issue occurs sporadically and seems to affect only specific Xiaomi devices

Expected Behavior (which is the case for almost 98% of android users)

  • The JavaScript event loop should continue running in the background while the call is ringing, even when the app is in headless mode.
  • setTimeout (or any async function) should execute after the expected delay (it is killer feature as we want to autodecline the call after some timeout)

Actual Behavior on some Xiaomi devices in some rear cases

  • JavaScript execution appears to be frozen until user interaction.
  • Delayed callbacks (setTimeout, setInterval, Promises, redux forks api, rxjs intervals) are postponed indefinitely until an event wakes up the process.

Environment

  • react-native-callkeep 4.3.13
  • react-native 0.74.1
  • @react-native-firebase/messaging 20.3.0
  • Platform: Android
  • All required and Xiaomi-specific extra permissions are enabled.

I am unable to repeat the issue locally as i dont have a proper device, I can confirm the issue exists with a huge amount of logs collected from the user devices and user feedbacks

Any ideas on the issue and how to ensure JS execution remains active in all cases?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant