react-native-callkeep icon indicating copy to clipboard operation
react-native-callkeep copied to clipboard

[iOS] App hangs when calling endCall before startCall transaction is received

Open ryanmcclure4 opened this issue 5 years ago • 1 comments

Bug report

  • Reproduced on:
  • [x] iOS
  • [ ] Android

Description

If the user initiates an outbound call using RNCallKeep.startCall and then calls RNCallKeep.endCall before the requestTransaction from startCall is completed, the app will hang. This can happen when the user immediately tries to end the call, if they have made a mistake etc... No crash, but the app becomes unresponsive. Device logs show the following from RNCallKeep:

[RNCallKeep][startCall] uuidString = f3119474-553d-413e-b621-1d50917fea24
[RNCallKeep][requestTransaction] transaction = <CXTransaction 0x283f04ec0 UUID=A1CB65BE-183F-480C-9278-D0A2AD532719 isComplete=0 actions=(
    "<CXStartCallAction 0x280b2d0e0 UUID=FB3A93F9-F2D6-49F9-A8B1-25769A16BA1F state=0 commitDate=(null) callUUID=F3119474-553D-413E-B621-1D50917FEA24 handle=<CXHandle 0x283f04bc0 type=Generic value=+18582844613> contactIdentifier=+18582844613 video=0 relay=0 upgrade=0 retry=0 emergency=0 isVoicemail=0 ttyType=0 localLandscapeAspectRatio={0, 0} localPortraitAspectRatio={0, 0} dateStarted=(null) localSenderIdentityUUID=(null) shouldSuppressInCallUI=0>"
)>
[RNCallKeep][endCall] uuidString = f3119474-553d-413e-b621-1d50917fea24
[RNCallKeep][requestTransaction] transaction = <CXTransaction 0x283f18b00 UUID=E27C261D-EA9B-4F46-B90F-23BB65D415C6 isComplete=0 actions=(
    "<CXEndCallAction 0x282cdf940 UUID=79D214FB-3777-4577-8A46-96CED245A59F state=0 commitDate=(null) callUUID=F3119474-553D-413E-B621-1D50917FEA24 dateEnded=(null)>"
)>
[RNCallKeep][requestTransaction] Requested transaction successfully

And the logs stop there. In a normal use case where the transaction from startCall completes before endCall is called, this is what the logs look like:

[RNCallKeep][startCall] uuidString = 86f74ed7-901e-4e4b-92b2-4bc689d698f2
[RNCallKeep][requestTransaction] transaction = <CXTransaction 0x2838f0b80 UUID=AA13EA13-2666-4A1E-AF2E-5E0821D97A36 isComplete=0 actions=(
    "<CXStartCallAction 0x280b15290 UUID=F1760FB7-1788-4EAF-A009-48B15E568F00 state=0 commitDate=(null) callUUID=86F74ED7-901E-4E4B-92B2-4BC689D698F2 handle=<CXHandle 0x2838f0b40 type=Generic value=+18582844613> contactIdentifier=+18582844613 video=0 relay=0 upgrade=0 retry=0 emergency=0 isVoicemail=0 ttyType=0 localLandscapeAspectRatio={0, 0} localPortraitAspectRatio={0, 0} dateStarted=(null) localSenderIdentityUUID=(null) shouldSuppressInCallUI=0>"
)>
[RNCallKeep][requestTransaction] Requested transaction successfully
[RNCallKeep][CXProviderDelegate][provider:performStartCallAction]
[RNCallKeep][configureAudioSession] Activating audio session
[RNCallKeep][CXProviderDelegate][provider:didActivateAudioSession]
[RNCallKeep][configureAudioSession] Activating audio session
[RNCallKeep][endCall] uuidString = 86f74ed7-901e-4e4b-92b2-4bc689d698f2
[RNCallKeep][requestTransaction] transaction = <CXTransaction 0x2838f8fc0 UUID=8E4B9D4B-CAF6-4B1A-8591-9738EA4882F1 isComplete=0 actions=(
    "<CXEndCallAction 0x282ca0040 UUID=92F0E883-DF6E-440E-A2F0-54C4E5971E76 state=0 commitDate=(null) callUUID=86F74ED7-901E-4E4B-92B2-4BC689D698F2 dateEnded=(null)>"
)>
[RNCallKeep][requestTransaction] Requested transaction successfully
[RNCallKeep][CXProviderDelegate][provider:performEndCallAction]
[RNCallKeep][CXProviderDelegate][provider:didDeactivateAudioSession]

So it seems that if endCall is triggered while startCall's transaction is still being processed, something goes wrong and we never hear the performEndCallAction from the CXProviderDelegate.

I'm thinking the best way to mitigate this would be to make startCall asynchronous, and have the return dependent on performEndCallAction being called. I'm not too versed in Objective C...is something like this possible? Otherwise, I'm not sure how we can avoid this type of race condition.

Steps to Reproduce

  • Start a call with startCall
  • Call endCall quickly afterwards

Versions

- Callkeep: 3.1.1
- React Native: 0.63.0
- iOS: 14.1

ryanmcclure4 avatar Nov 03 '20 19:11 ryanmcclure4

i also have same issue...

  • React Native: 0.63.4
  • iOS: 15

KolissnikBogdan avatar Nov 10 '21 15:11 KolissnikBogdan