From 86133e38cdb636bacbfdb0e46a9e528e943f87c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Moska=C5=82a?= <91079590+moskalakamil@users.noreply.github.com> Date: Wed, 21 Jan 2026 23:37:51 +0100 Subject: [PATCH] fix: video not loading when external subtitles are malformed (#4822) --- .../ios/core/Utils/ExternalSubtitlesUtils.swift | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/react-native-video/ios/core/Utils/ExternalSubtitlesUtils.swift b/packages/react-native-video/ios/core/Utils/ExternalSubtitlesUtils.swift index ab175d11..44165fe8 100644 --- a/packages/react-native-video/ios/core/Utils/ExternalSubtitlesUtils.swift +++ b/packages/react-native-video/ios/core/Utils/ExternalSubtitlesUtils.swift @@ -67,11 +67,18 @@ enum ExternalSubtitlesUtils { withMediaType: .text, preferredTrackID: kCMPersistentTrackID_Invalid ) { - try compositionTextTrack.insertTimeRange( - CMTimeRange(start: .zero, duration: textTrack.timeRange.duration), - of: textTrack, - at: .zero - ) + do { + try compositionTextTrack.insertTimeRange( + CMTimeRange(start: .zero, duration: textTrack.timeRange.duration), + of: textTrack, + at: .zero + ) + } catch { + print( + "[ReactNativeVideo] Failed to insert text track into composition: \(error.localizedDescription). Language: \(textTrack.languageCode ?? "unknown"). Continuing without this subtitle track." + ) + continue + } compositionTextTrack.languageCode = textTrack.languageCode compositionTextTrack.isEnabled = true