Skip to content

JS call stack freezes after displayIncomingCall until user interaction #828

Open
@dkornilove

Description

@dkornilove

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions