react-native-webrtc / react-native-webrtc/react-native-callkeep

JS call stack freezes after displayIncomingCall until user interaction

Open
#828 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.1k
Forks
511
Avg merge
9h 12m
Merged PRs (30d)
2

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The report names react-native-callkeep, Firebase background handling, displayIncomingCall, and the didDisplayIncomingCall event, but no repository files or tests. Start by tracing the Android call-display and headless-JS paths, then reproduce or instrument the Xiaomi-specific freeze; done means delayed JavaScript callbacks continue while the call is ringing.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript, react-native
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.