fix(ios): prevent UI freeze from sync artwork fetch and duration access#148
Open
erik-lissen wants to merge 6 commits intoevergrace-co:mainfrom
Open
fix(ios): prevent UI freeze from sync artwork fetch and duration access#148erik-lissen wants to merge 6 commits intoevergrace-co:mainfrom
erik-lissen wants to merge 6 commits intoevergrace-co:mainfrom
Conversation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Data(contentsOf:) and semaphore-based fetch blocked threads during slow network conditions. On failure, onError() tore down the entire player. Now uses URLSession with 10s timeout and emits soft PLAYBACK_ERROR on failure instead of destroying playback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Accessing duration on an AVAsset synchronously blocks the calling thread while fetching stream metadata (especially m3u8/HLS). Duration is already set via progress events once the player item is loaded. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Capture currentTrack before starting async artwork fetch and verify it still matches when the fetch completes - prevents stale artwork from overwriting the lock screen when rapidly switching tracks. Also call session.finishTasksAndInvalidate() in the completion handler to properly clean up the URLSession and avoid resource leaks.
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.
Fixes #147
Summary
Fixes two iOS blocking issues that cause the app to freeze on slow/bad networks:
Artwork fetch blocked threads -
Data(contentsOf:)and semaphore-based URLSession calls blocked GCD threads while fetching artwork for the lock screen. On failure,onError()tore down the entire player. Now uses fully asyncURLSessionwith a 10s timeout and emits a softPLAYBACK_ERRORon failure.item.asset.duration.secondsblocked on HLS - AccessingAVAsset.durationsynchronously forces metadata loading, which requires fetching and parsing the m3u8 playlist. Removed this synchronous access; duration is already set via progress events once the player item is loaded.Artwork is now optional - Empty or missing artwork no longer causes validation failures or player errors. The
AudioProTrack.artworkfield is now optional in the TypeScript type and all JS/native validation.Reproduction
Changes
src/types.ts- Makeartworkoptional inAudioProTracksrc/utils.ts- Allow empty artwork in validationios/AudioPro.swift- Three changes:guardstatementURLSession+ 10s timeoutitem.asset.duration.secondsaccessTest plan