Conversation
In TNSPlayer.playFromUrl, the NSURLSession completion handler rejects the promise when the download errors but does not return, so execution falls through to `SFBInputSource.inputSourceWithData(data)` with a null `data`, crashing on iOS. Return after reject so the handler bails out cleanly.
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.
Problem
On iOS,
TNSPlayer.playFromUrlcrashes when the audio download fails. In theNSURLSession.dataTaskWithURLCompletionHandlercallback, an error is handled by rejecting the promise — but execution does not stop, so it falls through to:When the request errors,
dataisnull, soSFBInputSource.inputSourceWithData(data)(and the decoder init that follows) runs on invalid data and crashes the app. This shows up in practice as a crash/error when navigating away mid-load or when a track fails to download.Fix
Return after rejecting so the handler bails out cleanly on error:
One line,
src/audio/player.ios.ts. The other error branches in this handler alreadyreturn reject(...); this makes the download-error branch consistent with them.Testing
We've been running this exact change in production (iOS) via
patch-packageagainst@nativescript-community/audio@6.4.14, and it resolves the crash. The change is a control-flow guard only — no behavior change on the success path.