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 crash when long-pressing stream while player is starting #7704

Merged
merged 2 commits into from
Feb 9, 2022

Conversation

Stypox
Copy link
Member

@Stypox Stypox commented Jan 25, 2022

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

This PR fixes a NullPointerException in PlayerHolder.getQueueSize() that could happen when the player's queue is null, i.e. when the player is starting. It also adds @Nullable here and there so that Android Studio's linter reports risks of NPEs.
I think this PR should be merged before the next release as it's just adding an if (... != null) but solves a big issue.

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.

Due diligence

Fix NullPointerException in PlayerHolder.getQueueSize() and add `@Nullable` here and there so that the linter reports risks of NPEs
@Feuerswut
Copy link

Seems to work. Its now extremely fast, so I dont know weather I reproduced the issue exactly but no crashes yet.

litetex
litetex previously approved these changes Jan 25, 2022
Copy link
Member

@litetex litetex left a comment

Choose a reason for hiding this comment

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

Code LGTM

@goyalyashpal
Copy link
Contributor

goyalyashpal commented Jan 27, 2022

just for records, this does fix not #7608 , i have given my input over that issue itself

@Stypox
Copy link
Member Author

Stypox commented Jan 27, 2022

@yashpalgoyal1304 I fixed your problem in the last commit, please check again the APK ;-)
Now the "Enqueue" button will just not show up if the playQueue is null, i.e. not available

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

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

0.0% 0.0% Coverage
16.0% 16.0% Duplication

@Stypox
Copy link
Member Author

Stypox commented Jan 27, 2022

Ignore the failure by sonarcloud, I just had to edit many duplicated lines, which will be solved by #7570

Copy link
Member

@litetex litetex left a comment

Choose a reason for hiding this comment

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

Code LGTM 😄

However I didn't test it so far...

@goyalyashpal
Copy link
Contributor

goyalyashpal commented Jan 27, 2022

I tested it,

and imo, showing the Enqueue option but graying it out (with properly chosen colors) will be more indicative and more fool proof.

what do others think??

@litetex
Copy link
Member

litetex commented Jan 27, 2022

@yashpalgoyal1304
Thank you for the feedback

In my opinion not showing the option is enough:

  • When it's grayed out/disabled a user may wait until it gets enabled which wouldn't happen. If we implement "the enabling" it would likely require a new PR because the current code was not designed for such things
  • It doesn't happen so often
  • A user can simply retry long-pressing
  • For now it fixes the crashes - We/You can open an additional feature request after it was fixed 😄

@goyalyashpal
Copy link
Contributor

fair 👍 (:

@eternal-sorrow
Copy link

So this PR does not fix the problem, just masks it by hiding the "Enqueue" menu option while loading? And if I want to quickly enqueue several videos, I have to wait while it loads?

@litetex
Copy link
Member

litetex commented Feb 9, 2022

So this PR does not fix the problem

It fixes the crash by not allowing to enqueue anything while the player is not ready for it.

And if I want to quickly enqueue several videos, I have to wait while it loads?

I assume so. But it shouldn't happen so often in the first place.
Usually people play whole playlists or actually watch the video.

See also → We/You can open an additional feature request after it was fixed 😄(from #7704 (comment))

@litetex litetex merged commit be95d7f into TeamNewPipe:dev Feb 9, 2022
This was referenced Feb 11, 2022
@goyalyashpal

This comment was marked as resolved.

@Stypox Stypox deleted the fix-stream-menu-crash branch August 4, 2022 09:49
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)
Projects
None yet
6 participants