Skip to content

Conversation

shi-su
Copy link

@shi-su shi-su commented Oct 2, 2025

ℹ️ Description

There are race conditions in video client stop function that may lead to a crashes if multiple threads of video client stop are triggered at the same time (e.g., pointer deallocation, reference counter update). The purpose of this change is to avoid such crashes.

Issue #, if available

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
    • README update
    • CHANGELOG update
    • guides update
  • This change requires a dependency update
    • Amazon Chime SDK Media
    • Other (update corresponding legal documents)

🧪 How Has This Been Tested?

describe the tests that you ran to verify your changes, any relevant details for your test configuration
Smoke tested and verified crash doesn't happen when ending a meeting

  1. Have an android attendee join a meeting
  2. Leave the meeting by pressing the red hang up button
  3. Verify no crash happens

Unit test coverage

  • Class coverage:
  • Line coverage:

Additional Manual Test

  • Pause and resume remote video
  • Switch local camera
  • Rotate screen back and forth

📱 Screenshots, if available

provide screenshots/video record if there's a UI change in demo app

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@shi-su shi-su marked this pull request as ready for review October 2, 2025 17:54
georgezy-amzn
georgezy-amzn previously approved these changes Oct 2, 2025

eglCore?.release()
eglCore = null
eglCore?.release()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we included this in the mutex scope?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we only put videoClientStateController.stop() under mutex, multiple eglCore?.release() may be triggered at the same time, this is another race condition that will trigger a crash for eglCore reference counter below 0. Added a comment.

videoClientObserver.primaryMeetingPromotionObserver = null

videoClientStateController.stop()
videoClientStopMutex.withLock {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were we able to reproduce? Was there a stack? Can we add a comment here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was reproducible with new webrtc version. Added a comment here to explain the crash

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.

3 participants