Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix seekbar preview crashes #11584

Merged
merged 4 commits into from
Oct 10, 2024

Conversation

Thompson3142
Copy link
Contributor

@Thompson3142 Thompson3142 commented Oct 2, 2024

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

Added error handling for recycled bitmaps and fixed the issue for specific videos crashing when the preview bar was pulled to the end twice.
Bitmap.createBitmap allows itself to NOT copy the bitmap if it is identical to the one it got passed. Since the same object is passed for bitmaps where nothing is cut out, recycling this bitmap leaves it unusable for later use.
Reference: https://stackoverflow.com/a/23683075 (the first comment to that answer)

Fixes the following issue(s)

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

@github-actions github-actions bot added the size/small PRs with less than 50 changed lines label Oct 2, 2024
@Thompson3142
Copy link
Contributor Author

Always happy to receive feedback on commenting style, extra logging, different solutions to the problem, or the PR itself :)

@ShareASmile ShareASmile added bug Issue is related to a bug player Issues related to any player (main, popup and background) labels Oct 2, 2024
@Thompson3142
Copy link
Contributor Author

Just to add some context to what happens in the linked issue:

  1. The user skips to the end of the video by using the seekbar
  2. Since there is only one bitmap remaining (in some videos with the right length) Bitmap.createBitmap does not change the source bitmap so it returns the instance of the source bitmap
  3. The user skips to the beginning of the video, since the source image was passed it is recycled in the process
  4. The user skips to the end of the video again, but the image that should create the preview was recycled -> crash

Copy link
Member

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@Thompson3142
Copy link
Contributor Author

Sorry for interupting but i just realized that i actually do not check if the bitmap needs to be copied 🤦. Copying without that is both unneccessary and could produce memory leaks if i understand bitmaps correctly.

Copy link

sonarcloud bot commented Oct 6, 2024

@TobiGr TobiGr merged commit eb9f300 into TeamNewPipe:dev Oct 10, 2024
6 checks passed
JL0000 pushed a commit to JL0000/NewPipe that referenced this pull request Nov 10, 2024
Fixed crashes from recycled bitmaps by creating real copies of bitmaps if necessary + some minor refactoring
@Stypox Stypox mentioned this pull request Nov 17, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is related to a bug player Issues related to any player (main, popup and background) size/small PRs with less than 50 changed lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

App crashes when seeking to the end of a specific video
3 participants