Skip to content

fix(video): Prevent crash and ANR during content share stop#706

Merged
georgezy-amzn merged 2 commits into
developmentfrom
content-crash-fix
Jun 15, 2026
Merged

fix(video): Prevent crash and ANR during content share stop#706
georgezy-amzn merged 2 commits into
developmentfrom
content-crash-fix

Conversation

@georgezy-amzn

Copy link
Copy Markdown
Collaborator

ℹ️ Description

Three fixes for content share teardown:

  1. DefaultContentShareVideoClientController: Guard stopVideoShare() with isSharing check to prevent re-entrant calls. The callback from MediaProjection.onStop() and onContentShareStopped both trigger additional stopVideoShare() calls, causing javaStopService()+destroy() to execute 3-4 times on the main thread, blocking it past the 5s ANR threshold.

  2. DefaultContentShareVideoClientController: Disconnect the video source adapter and stop sending BEFORE destroying the video client. Prevents frames flowing into freed native objects.

  3. DefaultSurfaceTextureCaptureSource: Cancel pending handler messages (minFps resend timer) in stop() to prevent delayed frame delivery into a torn-down pipeline.

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

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.

Three fixes for content share teardown:

1. DefaultContentShareVideoClientController: Guard stopVideoShare()
   with isSharing check to prevent re-entrant calls. The callback from
   MediaProjection.onStop() and onContentShareStopped both trigger
   additional stopVideoShare() calls, causing javaStopService()+destroy()
   to execute 3-4 times on the main thread, blocking it past the 5s ANR
   threshold.

2. DefaultContentShareVideoClientController: Disconnect the video
   source adapter and stop sending BEFORE destroying the video client.
   Prevents frames flowing into freed native objects.

3. DefaultSurfaceTextureCaptureSource: Cancel pending handler messages
   (minFps resend timer) in stop() to prevent delayed frame delivery
   into a torn-down pipeline.
hensmi-amazon
hensmi-amazon previously approved these changes Jun 11, 2026
dinmin-amzn
dinmin-amzn previously approved these changes Jun 11, 2026
Move javaStopService() + destroy() to a background thread to prevent
ANR. These calls block for 1-2s via signaling_thread_->BlockingCall()
waiting for WebRTC peer connection close and signaling teardown.

The video source adapter is disconnected synchronously on the main
thread to prevent frames reaching freed native objects, then actual
native cleanup runs asynchronously.
@georgezy-amzn georgezy-amzn dismissed stale reviews from dinmin-amzn and hensmi-amazon via 9693498 June 12, 2026 08:16
@georgezy-amzn georgezy-amzn merged commit 3fa0d5a into development Jun 15, 2026
4 of 7 checks passed
@georgezy-amzn georgezy-amzn deleted the content-crash-fix branch June 15, 2026 17:44
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