fix(player): Fix scaleX being NaN on minimize to background app switch#12952
fix(player): Fix scaleX being NaN on minimize to background app switch#12952theimpulson merged 3 commits intodevfrom
Conversation
|
@theimpulson This PR fixes crashes which have not been reported in the 0.28.0 release and only with recent nightly releases. We did not touch any related files recently which leads me to the suspicion that a dependecy update might be the cause for this issue. Any ideas? |
I think it might be exoplayer. I see this on exoplayer 2.19.0 changelog: |
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.
If the video's hieght is 0, the aspectRatio is set to Float.NaN which can cause further issues. Do not assign invalid values for the aspectRatio.
c62db16 to
b0e766d
Compare
|
Thanks. That's the cause. I kept the previous two commits to ensure no bad values are used and added a commit to tackle the cause where it should be. The interesting question is why I am not able to reproduce the error on the emulator or my phone. But I don't think we have to answer that 😅 |
b0e766d to
465979e
Compare
|
LGTM |
What is it?
Description of the changes in your PR
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:
For the fill stacktrace and description, see #12925 (comment) and #12955.
scaleXis set inonMeasure()in whichwidthcould be 0 in theory and this leading to a division by zero of a float which results in an assignment ofFloat.NaN.The set
aspectRatiois, but must not be not finite, which causes an assignment ofFloat.NaN.Remarks
Note for reviewers
The second finding actually fixes the crash while the first does not as noted in #12955. But I'd like to keep both safeguards. I was initially expecting to find a View that was not hidden or destroyed. The aspect ration seems to be not finite which means that the video width and height retrieved from Exoplayer are 0. This could mean that the player is not detached or destroyed as expected. However, I am unable to reproduce this crash and this is more a symptom fix than actually taking a shot at the root cause. If someone is able to reproduce this, please take a look at it!
Fixes the following issue(s)
This is a potential fix for the stacktrace given in #12925 (comment)
APK testing
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.
Due diligence