Skip to content

fix(player): guard against a non-finite video aspect ratio crashing the player layout#57

Open
Priveetee wants to merge 1 commit into
InfinityLoop1308:devfrom
Priveetee:fix/2515-nan-aspect-ratio
Open

fix(player): guard against a non-finite video aspect ratio crashing the player layout#57
Priveetee wants to merge 1 commit into
InfinityLoop1308:devfrom
Priveetee:fix/2515-nan-aspect-ratio

Conversation

@Priveetee

Copy link
Copy Markdown
Contributor

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.setScaleX during layout, which throws and crashes the player. This sanitizes the aspect ratio so the measure path skips scaling instead.

Problem

java.lang.IllegalArgumentException: Cannot set 'scaleX' to Float.NaN
    at android.view.View.setScaleX(View.java:20505)
    at org.schabi.newpipe.views.ExpandableSurfaceView.onLayout(...)

My read: setAspectRatio stores the raw ratio, and when it's NaN the videoAspectRatio == 0 guard in onMeasure doesn't catch it (NaN != 0), so the scale ends up NaN and gets pushed into setScaleX during layout.

Changes

  • ExpandableSurfaceView.setAspectRatio: sanitize a non-finite aspect ratio to 0 ("no ratio"), so onMeasure skips scaling.
  • ExpandableSurfaceView.onLayout: defensively never pass a non-finite scale to setScaleX / 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.

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