mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-12-31 03:59:05 +00:00
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.
This commit is contained in:
@@ -35,12 +35,12 @@ public class ExpandableSurfaceView extends SurfaceView {
|
||||
&& resizeMode != RESIZE_MODE_FIT
|
||||
&& verticalVideo ? maxHeight : baseHeight;
|
||||
|
||||
if (height == 0) {
|
||||
if (width == 0 || height == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
final float viewAspectRatio = width / ((float) height);
|
||||
final float aspectDeformation = videoAspectRatio / viewAspectRatio - 1;
|
||||
final float aspectDeformation = (videoAspectRatio / viewAspectRatio) - 1;
|
||||
scaleX = 1.0f;
|
||||
scaleY = 1.0f;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user