Skip to content

Commit 718335d

Browse files
committed
fix(player): Fix scaleX being NaN on minimize to background app switch
This aims to fix the following Exception which might occour when watching a live stream and switching the app while 'minimize to backgorund' is enabled: java.lang.IllegalArgumentException: Cannot set 'scaleX' to Float.NaN at android.view.View.sanitizeFloatPropertyValue(View.java:17479) at android.view.View.sanitizeFloatPropertyValue(View.java:17453) at android.view.View.setScaleX(View.java:16822) at org.schabi.newpipe.views.ExpandableSurfaceView.onLayout(ExpandableSurfaceView.java:71) scaleX is set in onMeasure() in which width could be 0 in theory and this leading to a division by zero of a float which results in an assignment of Float.NaN.
1 parent 2dde0fe commit 718335d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

app/src/main/java/org/schabi/newpipe/views/ExpandableSurfaceView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec
3535
&& resizeMode != RESIZE_MODE_FIT
3636
&& verticalVideo ? maxHeight : baseHeight;
3737

38-
if (height == 0) {
38+
if (width == 0 || height == 0) {
3939
return;
4040
}
4141

4242
final float viewAspectRatio = width / ((float) height);
43-
final float aspectDeformation = videoAspectRatio / viewAspectRatio - 1;
43+
final float aspectDeformation = (videoAspectRatio / viewAspectRatio) - 1;
4444
scaleX = 1.0f;
4545
scaleY = 1.0f;
4646

0 commit comments

Comments
 (0)