futo-org / grayjay-android

Read-only mirror of Grayjay repo for issue tracking
https://gitlab.futo.org/videostreaming/grayjay
Other
752 stars 48 forks source link

Integer overflow leading to incorrect file size being reported in the player settings pane #1420

Open aupereira opened 2 weeks ago

aupereira commented 2 weeks ago

What happened?

When playing a Youtube video, if you open the player settings pane and the file size of a given video at a given quality is sufficiently large to overflow the 32-bit integer holding the size of the video in bytes, it will report the wrong size. See the example below with the 4k video size being incorrectly listed in the hundreds of MB:

grayjay_overflow_example

The issue seems to reside within app/src/main/java/com/futo/platformplayer/helpers/VideoHelper.kt, which contains the function (estimateSourceSize) that is used to get a file size estimate in bytes. estimateSourceSize returns an Int rather than a Long, leading to the wrong value being eventually passed into the toHumanBytesSize function in app/src/main/java/com/futo/platformplayer/Extensions_Formatting.kt, which is responsible for reporting the estimated file size in the player settings pane.

I haven't tested this with plugins other than Youtube, but seeing as it is within the core, I would suspect that this would be an issue for other plugins as well.

The issue was tested with: Grayjay v264 Youtube Plugin v207

This bug should apply to all devices, but it was discovered on a Google Pixel 7a running Android 15 (firmware AP3A.241005.015).

Grayjay Version

264

What plugins are you seeing the problem on?

Youtube

Plugin Version

207

When do you experience the issue?

Relevant log output

No response

support-grayjay commented 4 days ago

Lovely bug report. Thank you @aupereira this will be fixed.