wire-ios_legacy icon indicating copy to clipboard operation
wire-ios_legacy copied to clipboard

CallKit not working anymore if the app is killed manually

Open lucifer662607004 opened this issue 3 years ago • 1 comments

Checklist (please check before submitting)

  • [ ☑️] I checked the existing issues, and the issue was not reported before.

The problem

  1. Open Wire
  2. Swipe up to put Wire on background
  3. Wait for an incoming call, make sure CallKit is popping up and everything is working fine by now.
  4. Swipe up again and kill Wire manually on iOS multi-task list
  5. Wait for another incoming call, nothing will happen. CallKit is not working anymore.
  6. If you try above steps several times you will end up losing CallKit completely, until you reinstall the app next time.

Environment

  • Wire version that exhibits the issue: Latest Wire 3.103 on App Store
  • Last Wire version that did not exhibit the issue (if applicable): N/A
  • iOS version used to run Wire: iOS 15.6.1
  • iOS device type: iPhone 13 mini
  • Mobile network type (EDGE/LTE/Wi-Fi/Offline): WiFi
  • Exact date, time and timezone (only for the crash issues): N/A

Details

it's 100% reproducible on my iPhone

Calling Debug logs (only for calling issues)

I think you can reproduce on your own device.

Screenshots

N/A

lucifer662607004 avatar Aug 22 '22 10:08 lucifer662607004

I debug through it with console, the problem is at WireSyncEngine.

Successfully reporting incoming call in callkit requires the code report it on 'didReceiveIncomingPushWith' SYNCHRONOUSLY, according to apple document. When the app is killed and started by a Pushkit event, Wire is trying to load the background sessions ASYNCHRONOUSLY from core data. Which means the backgroundUserSession will be nil right before the callkit is reported. And the upcoming reporting will fail. In which case Wire will be killed by iOS system eventually with fatal signals. If the app is in the background, the background user session is already loaded. Wire will report it successfully on 'didReceiveIncomingPushWith'

My advise is to report a fake incoming call if the background session isn't ready, with the information in the Pushkin payload. Update the fake call to an actual one after the background session is ready.

lucifer662607004 avatar Sep 05 '22 03:09 lucifer662607004