fix(ios): resolve threading issues and crash on dead links#198
Merged
kdroidFilter merged 3 commits intomasterfrom Apr 11, 2026
Merged
fix(ios): resolve threading issues and crash on dead links#198kdroidFilter merged 3 commits intomasterfrom
kdroidFilter merged 3 commits intomasterfrom
Conversation
- Move all Compose state mutations to main thread (KVO observers, notification observers, metadata extraction) - Defer _hasMedia=true until AVPlayerItem reaches readyToPlay, preventing UIKitView creation with an invalid player item - Extract metadata only when item is ready, avoiding ObjC NSExceptions from accessing track properties on unloaded/failed assets - Guard periodic time observer with readyToPlay status check - Guard AVPictureInPictureController creation with isPictureInPictureSupported - Reduce position update timer from 60fps to 15fps - Use NSOperationQueue.mainQueue for all notification observers - Implement _error state properly (was hardcoded to null)
Files picked via UIDocumentPickerViewController require security-scoped access. Without calling startAccessingSecurityScopedResource(), AVPlayer cannot read the file and playback silently fails. - Call startAccessingSecurityScopedResource() in openFile() before passing the URL to AVPlayer - Track the scoped file and call stopAccessingSecurityScopedResource() on cleanup - Refactor openUri into openNsUrl for shared logic reuse
iOS cannot present a UIDocumentPickerViewController while a ModalBottomSheet is still visible (stacked modals not supported). Use a pendingPick flag + LaunchedEffect to launch the picker only after the sheet is fully dismissed. Also revert the unnecessary security-scoped resource access changes in VideoPlayerState.
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
_hasMedia = trueuntil AVPlayerItem reachesreadyToPlaystatus, preventingVideoPlayerSurfacefrom creating aUIKitView+AVPictureInPictureControllerwith an invalid player item that throws ObjC NSExceptions during Compose recompositionmutableStateOfmutations to the main thread — KVO observers now dispatch to main before writing state, notification observers useNSOperationQueue.mainQueue, metadata extraction happens only onreadyToPlayitem.error,reasonForWaitingToPlay, or track properties from KVO callbacks — only read primitive/enum values (status,timeControlStatus)isPictureInPictureSupported()before creatingAVPictureInPictureController(throws NSException if unsupported)_erroris now a propermutableStateOf(was hardcoded tonull)Test plan