Skip to content

Stop iOS crashing when answering a call whose invite is already gone - #3

Merged
andrejunges merged 1 commit into
close-mainfrom
port/close-mobile-643
Aug 3, 2026
Merged

Stop iOS crashing when answering a call whose invite is already gone#3
andrejunges merged 1 commit into
close-mainfrom
port/close-mobile-643

Conversation

@andrejunges

@andrejunges andrejunges commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

What

Guards performAnswerVoiceCallWithUUID:completion: in ios/TwilioVoiceReactNative+CallKit.m against a missing CallInvite. If CallKit delivers an answer action after the invite has already been removed from callInviteMap (the call was cancelled/ended, or already answered), the method now logs, calls the completion handler with NO, and returns instead of proceeding with a nil invite.

Why

The existing NSAssert is compiled out in release builds (NS_BLOCK_ASSERTIONS), so execution fell through to +[TVOAcceptOptions optionsWithCallInvite:] with a nil invite, which raises NSInvalidArgumentException ("A call invite is required.") and crashes the app. With this change, answering a since-ended call is a graceful no-op.

In our production crash reporting this is the single largest native crash on the app — roughly 49,800 lifetime events across ~750 users (issue links on the internal PR referenced below).

Ported from closeio/close-mobile#643 as part of the fork migration.

Upstream candidate

This is a strong candidate to upstream: twilio/twilio-voice-react-native recently landed an attempt at this exact problem class (their PR twilio#695, "[VBLOCKS-6682] feat: ignore accept and reject for invalid callinvites") and then reverted it in twilio#699, so the underlying crash is still unaddressed upstream.

🤖 Generated with Claude Code

When CallKit delivers an answer action after the CallInvite has already
been removed from callInviteMap (call cancelled/ended or already
answered), the NSAssert guarding it is compiled out in release builds,
so execution fell through to +[TVOAcceptOptions optionsWithCallInvite:]
with a nil invite, raising NSInvalidArgumentException and crashing the
app. Bail out gracefully instead, so answering a since-ended call is a
no-op.

Ported from closeio/close-mobile#643.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@andrejunges andrejunges self-assigned this Aug 3, 2026
@andrejunges
andrejunges requested a review from treycucco August 3, 2026 12:09
@andrejunges
andrejunges marked this pull request as ready for review August 3, 2026 12:09
@treycucco

Copy link
Copy Markdown

Interestingly, it looks like Twilio's referenced PR only handled android, and ours only handles Android? Do we not have this issue on Android?

@andrejunges

Copy link
Copy Markdown
Collaborator Author

Interestingly, it looks like Twilio's referenced PR only handled android, and ours only handles Android? Do we not have this issue on Android?

this is the android side fix #4

@andrejunges
andrejunges merged commit 3246ef2 into close-main Aug 3, 2026
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

Successfully merging this pull request may close these issues.

2 participants