Skip to content

fix: Crash when touching player controls during destruction#205

Merged
Jmilham21 merged 1 commit intomasterfrom
bug/player-destruction-race-condition
Jan 30, 2026
Merged

fix: Crash when touching player controls during destruction#205
Jmilham21 merged 1 commit intomasterfrom
bug/player-destruction-race-condition

Conversation

@Jmilham21
Copy link
Copy Markdown
Collaborator

What does this Pull Request do?

Fixes a race condition crash that occurs when player UI controls are touched during player destruction. The fix prevents touch events from reaching native SDK components that have already been torn down by:

  1. Adding an isDestroying flag to prevent re-entry into destroyPlayer()
  2. Immediately disabling all touch interactions on the player view before native SDK teardown begins
  3. Adding defensive null checks in RNJWPlayerViewManager for getPlayer() calls

Why is this Pull Request needed?

Users are experiencing crashes when navigating away from a player screen while interacting with controls (especially side seek or play/pause). The crash occurs because:

  1. Player destruction is triggered (e.g., navigation back, component unmount)
  2. UI views (SideSeekView, ControlsContainerView) are still visible and accepting touches
  3. Touch events propagate to listener callbacks
  4. Native SDK has already cleared/nulled internal listeners during teardown
  5. NPE occurs: Attempt to invoke interface method 'void com.jwplayer.ui.g.b()' on a null object reference

This is a timing issue where UI lifecycle and native SDK lifecycle aren't perfectly synchronized during destruction.

Are there any points in the code the reviewer needs to double check?

  1. Threading: The UI disable logic runs on the main thread via Handler.post() - verify this doesn't introduce any new timing issues
  2. Flag reset: The isDestroying flag is reset at the end of destroyPlayer() - confirm this is safe for component reuse scenarios
  3. Touch blocking completeness: Review if setClickable(false), setFocusable(false), setEnabled(false), and setOnTouchListener(null) fully prevent all touch event propagation

Are there any Pull Requests open in other repos which need to be merged with this?

No

Addresses Issue(s):

Internally raised ticket

@Jmilham21 Jmilham21 requested a review from a team as a code owner January 5, 2026 17:29
@Jmilham21 Jmilham21 merged commit 29c0f78 into master Jan 30, 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.

1 participant