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 channel avatar not loading correctly sometimes #10581

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

Stypox
Copy link
Member

@Stypox Stypox commented Nov 16, 2023

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

The fix just involves removing some really outdated code (6 years ago) added in 33e29be (blame). What that code did was setting the 'buddy' image to the uploader avatar as a placeholder, and then setting the actual image if it existed and after it had loaded. That code remained there up until now, but now it doesn't make sense anymore, since Picasso already takes care of setting placeholders.

The problem is, starting from #10066 the actual uploader image is set before those lines of code, making them do the wrong thing, i.e. always overwrite the currently set image.

But then why did the channel avatar image work normally sometimes? My guess is that since Picasso loads images in the background, when opening a video from scratch setting the placeholder still happened before Picasso finished loading the image. However when the image is already cached it's loaded much faster and therefore setting the placeholder happens after, effectively hiding the loaded image.

Supersedes #10517 which also removed those lines of code, but also made unneeded database changes.

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

The fix just involves removing some really outdated code (6 years ago) added in TeamNewPipe@33e29be#diff-38bd2cf1b92659b499c08e1cf6ac9ef384c7e13381b906f2f98c57cbb758756dR778 (blame: https://github.com/TeamNewPipe/NewPipe/blame/9318bb530619898c1e1f3f8a8c866f3d2e35ab0c/app/src/main/java/org/schabi/newpipe/detail/VideoItemDetailActivity.java#L778).
What that code did was setting the 'buddy' image to the uploader avatar as a placeholder, and then setting the actual image if it existed and after it had loaded.
That code remained there up until now, but now it doesn't make sense anymore, since Picasso already takes care of setting placeholders.
The problem is, starting from TeamNewPipe#10066 the actual uploader image is set before (not after) those lines of code, making them do the wrong thing, i.e. always overwrite the currently set image.
But then why did the channel avatar image work normally sometimes?
My guess is that since Picasso loads images in the background, when opening a video from scratch setting the placeholder still happened before Picasso finished loading the image.
However when the image is already cached it's loaded much faster and therefore setting the placeholder happens after, effectively hiding the loaded image.
@Stypox Stypox mentioned this pull request Nov 16, 2023
5 tasks
@Stypox Stypox changed the base branch from dev to release-0.26.0 November 16, 2023 21:59
Copy link

sonarcloud bot commented Nov 16, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@AudricV AudricV added bug Issue is related to a bug GUI Issue is related to the graphical user interface labels Nov 16, 2023
@Stypox Stypox mentioned this pull request Nov 16, 2023
21 tasks
@Stypox Stypox merged commit 988081d into TeamNewPipe:release-0.26.0 Dec 7, 2023
10 of 11 checks passed
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 GUI Issue is related to the graphical user interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Channel icon on stream details disappear sometimes
2 participants