Skip to content

fix: guard stale Android CallInvite acceptance - #713

Open
nhibberd wants to merge 3 commits into
twilio:mainfrom
nhibberd:fix/android-stale-callinvite-accept
Open

nhibberd wants to merge 3 commits into
twilio:mainfrom
nhibberd:fix/android-stale-callinvite-accept

Conversation

@nhibberd

Copy link
Copy Markdown

Submission Checklist

  • Updated the CHANGELOG.md to reflect the bug fix
  • Tested code changes and observed expected behavior in the example app
  • Performed a visual inspection of the Files changed tab for style consistency

All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.

  • I acknowledge that all my contributions will be made under the project's license.

Description

Prevents an Android native null-pointer crash when a CallInvite is cancelled after JavaScript calls accept() but before the queued main-thread acceptance runs.

CallInviteModuleProxy.getCallRecord() currently validates the invite before posting work to the main thread. A cancellation can remove or settle that invite before VoiceService.acceptCall() serializes its custom parameters, causing CallInvite.getCustomParameters() to be called through a null reference. JavaScript cannot catch this native main-thread crash.

This restores the intent of #695 after its CI-related revert in #699, while also closing the remaining race at the main-thread boundary and making invite serialization null-safe.

Breakdown

  • Resolve and validate the call record inside the main-thread runnable.
  • Reject acceptance when the invite is missing or no longer active.
  • Cache the validated invite for acceptance so concurrent cancellation cannot turn a later read into null.
  • Return empty custom parameters when a cancelled incoming invite is serialized.

Validation

  • yarn check
  • 523 Jest tests passed with 100% reported coverage.
  • TypeScript and ESLint checks passed.
  • Android Gradle compilation was not run locally because the test machine has no Java runtime.

Additional Notes

This is an internal defensive change with no public API changes.

This branch has not been deployed

No deployments
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.

1 participant