Repository navigation
Fix a hard crash when AVFoundation reports a non-finite estimatedDataRate - #936
Open
rochakagrawal wants to merge 1 commit into
Open
rochakagrawal wants to merge 1 commit into
rochakagrawal wants to merge 1 commit into
Conversation
AVMediaPlayerTrack.init read `estimatedDataRate` through `?? 0`, which only covers a nil assetTrack. The property itself is a non-optional Float, and AVFoundation returns it as NaN for a track whose data rate is not declared in the container - ordinary for progressive MP4s served over HTTP. That value went straight into `Int64(_: Float)`, which traps: EXC_BREAKPOINT, signal 5, seen by the viewer as a crash at the moment the item becomes ready to play, roughly three seconds into playback. Zero is the honest reading for an unmeasurable bitrate, and every finite input still produces the same answer as before. Two neighbours on the same paths get the same treatment, both reachable from the same KVO callbacks: - bufferingProgress divided by `preferredForwardBufferDuration` and clamped afterwards, so an infinite quotient reached `Int(_:)` before the clamp. - The `currentTime`/`totalTime` guard in KSVideoPlayer compared against `Double(Int.max)` bounds, but NaN compares false against every bound, so it passed the guard and trapped in `Int(_:)`. `isFinite` is now tested first. Verified with a model of Swift's conversion semantics: 4 traps on the old code, 0 on this one, identical results for every finite input.
Owner
|
这三个crash在lgpl分支已经修复好了 。 |
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.
AVMediaPlayerTrack.initreadsestimatedDataRatethrough?? 0, which only covers a nilassetTrack. The property itself is a non-optionalFloat, and AVFoundation returns it asNaNfor a track whose data rate is simply not declared in the container — ordinary for progressive MP4s served over HTTP.That value went straight into
Int64(_: Float), which traps:EXC_BREAKPOINT, signal 5. The viewer sees a crash at the instant the item becomes ready to play, roughly three seconds into playback.Zero is the honest reading for an unmeasurable bitrate, and every finite input still produces exactly the same answer as before.
Two neighbours on the same paths get the same treatment, both reachable from the same KVO callbacks:
bufferingProgressdivided bypreferredForwardBufferDurationand clamped afterwards, so an infinite quotient reachedInt(_:)before the clamp. The clamp now happens before the conversion; an infinite value means "more is buffered than the target asked for", which is 100.currentTime/totalTimeguard inKSVideoPlayercompared againstDouble(Int.max)bounds, butNaNcompares false against every bound, so it passed the guard and trapped inInt(_:).isFiniteis now tested first.Verified against a model of Swift's conversion semantics (an IEEE
fdivin the same shape): 4 traps on the current code, 0 on this one, with identical results for every finite input.Affected: any app that plays a container with an undeclared data rate. On iOS this is a hard crash, not a degradation. Kotlin returns 0 for a non-finite →
Intconversion, which is why the same file plays on Android and only iOS dies.