Skip to content

fix(SideloadedSubtitle): guard AVSubtitlesLoader state against concurrent mutation - #127

Open
Efka22 wants to merge 1 commit into
THEOplayer:mainfrom
Efka22:fix/sideloaded-subtitle-data-race
Open

fix(SideloadedSubtitle): guard AVSubtitlesLoader state against concurrent mutation#127
Efka22 wants to merge 1 commit into
THEOplayer:mainfrom
Efka22:fix/sideloaded-subtitle-data-race

Conversation

@Efka22

@Efka22 Efka22 commented Jul 8, 2026

Copy link
Copy Markdown

Problem

Playing a stream with side-loaded text tracks intermittently crashes on iOS with EXC_BAD_ACCESS in swift_release_dealloc.

AVSubtitlesLoader.requestMap (a Dictionary) and subtitles (an Array) are mutated from didInterceptPlaylistRequest(type:request:) and interceptResponse(type:url:data:)async callbacks that AVFoundation invokes concurrently for the master, variant and subtitle playlists. Concurrent mutation corrupts the collections' backing storage and crashes.

The unsynchronized requestMap was introduced in 11.0.3 (request interception for the user-agent fix); the crash has been observed in the field since.

Fix

Serialize all access to each collection through a dedicated NSLock (subtitlesLock, requestMapLock), applied via lock-guarded computed properties so no call sites change. The two collections are independent caches with no shared invariant, so they take separate locks; no code path holds both at once, so there is no lock-ordering/deadlock hazard.

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