fix(ios): prevent EXC_BREAKPOINT crash in HybridVideoPlayer.release()#4851
Open
erank-pixel wants to merge 1 commit intoTheWidlarzGroup:masterfrom
Open
fix(ios): prevent EXC_BREAKPOINT crash in HybridVideoPlayer.release()#4851erank-pixel wants to merge 1 commit intoTheWidlarzGroup:masterfrom
erank-pixel wants to merge 1 commit intoTheWidlarzGroup:masterfrom
Conversation
Fixes a crash (EXC_BREAKPOINT) in `HybridVideoPlayer.release()` observed on iOS 26 when the method is called from the JS thread via the Nitro bridge. Two issues are addressed: 1. **Double-release guard**: `release()` was called twice — once explicitly from JS cleanup (`useVideoPlayer` unmount) and again from Swift `deinit` when the Nitro GC collected the hybrid object. The second invocation accessed already-cleared state. An `isReleased` flag now prevents re-entry. The `deinit` no longer calls `release()` and instead performs minimal observer/player cleanup directly. 2. **Main-thread dispatch for AVPlayer teardown**: `release()` runs on the JS thread (via Nitro/JSI), but AVPlayer KVO observers and periodic time observers fire callbacks on the main thread. This data race corrupts internal state. AVPlayer and observer invalidation are now dispatched to the main thread via `DispatchQueue.main.sync` when not already there. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a crash (
EXC_BREAKPOINT) inHybridVideoPlayer.release()observed on iOS 26 when the method is called from the JS thread via the Nitro bridge during Hermes microtask processing.Crashlytics stack trace:
Two issues are fixed:
Double-release:
release()is called twice — once from JS cleanup (useVideoPlayerunmount →__destroy()→player.release()) and again from Swiftdeinitwhen the Nitro GC later collects the hybrid object. The second invocation accesses already-cleared state (event emitter, observers). AnisReleasedflag now prevents re-entry.deinitno longer callsrelease()— it performs only minimal observer/player cleanup directly.Thread safety:
release()runs on the JS thread (via Nitro/JSI bridge), butVideoPlayerObserverregisters KVO observers and a periodic time observer that fire callbacks on the main thread. Concurrent access from both threads corrupts internal state. AVPlayer operations and observer invalidation inrelease()(anddeinit) are now dispatched to the main thread viaDispatchQueue.main.syncwhen not already there.Environment