fix(player): guard against a non-finite video aspect ratio crashing the player layout#57
Open
Priveetee wants to merge 1 commit into
Open
Conversation
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.
Context (bug report):
Summary
I think this crash comes from a video with unknown / 0x0 dimensions: it yields a NaN (or Infinity) aspect ratio that becomes a non-finite scale passed to
View.setScaleXduring layout, which throws and crashes the player. This sanitizes the aspect ratio so the measure path skips scaling instead.Problem
My read:
setAspectRatiostores the raw ratio, and when it's NaN thevideoAspectRatio == 0guard inonMeasuredoesn't catch it (NaN != 0), so the scale ends up NaN and gets pushed intosetScaleXduring layout.Changes
ExpandableSurfaceView.setAspectRatio: sanitize a non-finite aspect ratio to 0 ("no ratio"), soonMeasureskips scaling.ExpandableSurfaceView.onLayout: defensively never pass a non-finite scale tosetScaleX/setScaleY.Validation
Honestly i couldn't reproduce the exact trigger on demand (it needs a 0x0 / not-yet-known video), so this is my best read of the stack trace plus a defensive guard rather than a measured before/after. The non-finite path looks like the only way a NaN reaches
setScaleX, and both the source and the layout call are now guarded. If anyone can repro it i'm happy to confirm.