TeamNewPipe / NewPipe

A libre lightweight streaming front-end for Android.
https://newpipe.net
GNU General Public License v3.0
31.02k stars 3.02k forks source link

Strange Playlist Order in the Add to Playlist preview #10993

Open Monstanner opened 4 months ago

Monstanner commented 4 months ago

Checklist

Affected version

0.27.0

Steps to reproduce the bug

Not really an issue

  1. Open New Pipe
  2. Add a Video to a Playlist (Either when you long press on a video or when you press the icon on a video)
  3. The order of the playlists is no longer alphabetical / numeric. At first I thought it was sorted by playlist creation date, but it looks more like thrown together.

Expected behavior

The order of the playlist should be the same as in the previous versions (0.26.1, etc.)

Actual behavior

Wildly thrown together playlist order. (Only in the Add to Playlist preview)

Screenshots/Screen recordings

No response

Logs

No response

Affected Android/Custom ROM version

Android 13 Vanilla

Affected device model

Nokia X10

Additional information

No response

SpazMahTazz commented 4 months ago

I can't replicate this, but on a semi-related note, new playlists now go to the top. I like the sort option but I also liked it when they were put in alphabetical order when they were created.

Monstanner commented 4 months ago

I can't replicate this, but on a semi-related note, new playlists now go to the top. I like the sort option but I also liked it when they were put in alphabetical order when they were created.

I know how to reproduce the bug. If you upgrade from 0.26.1 to 0.27.0 and then add a video to a playlist without rearranging a playlist first, the playlist will look messed up in the Add to Playlist Preview. However, if you rearrange a playlist, the preview will look the same as before. The issue can be closed.

Stypox commented 4 months ago

@Monstanner thank you for the details. Although this behavior is somewhat unintended, it's also something that can happen only right after upgrading to 0.27.0, so I wouldn't worry about it. It's ok that the order is not updated when querying playlists, but only when doing something with them.

Anyway, this can be fixed by adding a clause to the ORDER BY of some SQL query, in case someone wants to solve it.

ajgae commented 4 months ago

Hi, I noticed this strange behavior as well and wouldve been fine with manually reordering my playlists if they were to have only been messed up once by the update, but it seems that the problem persists in a way that is pretty annoying. Specifically, in my saved playlists, I have (i am using "local" to denote playlists that are created from within newpipe, and "remote" to denote playlists which are present on youtube, please tell me if there is a more fitting vocabulary):

local playlists seem not pose an issue, and user-created remote playlists seem fine too (i think one of them mightve exhibited strange behavior once, but this must be the one-time issue brought up by @Stypox). However, remote playlists autogenerated by youtube exhibit strange behavior:

  1. remote playlist is somewhere in the middle of my saved playlist tab
  2. i click on it to open it from the saved playlists tab, and then exit back to the saved playlist tab
  3. the playlist has been moved back all the way to the top of the tab

this seems to me like an actual bug that must be addressed, and i'd be interested in trying to contribute to solve it. however, it may be good to first attempt to confirm that it is happening for other newpipe 27.0 users too

ajgae commented 4 months ago

as a follow up to my last comment, i have tried to find the source of this behavior and i think i have a culprit.

  1. this line sets the display index to -1 for all remote playlists by default (so that new bookmarked playlists appear at the top of the bookmarks list, i would imagine)
  2. the only place in the entire codebase where setDisplayIndex is called on a PlaylistRemoteEntity is in BookmarkFragment.saveImmediate(), which is called by BookmarkFragment.onPause() (which corresponds with the moment at which the playlists are sent back all the way up by the bug)
  3. in saveImmediate(), debounceSaver.getIsModified() returns false so the function returns immediately. The code which computes and updates the display index for playlists is not executed. it seems that the issue is with the debounceSaver in some way, but i do not understand this part of the application very well.

I'm not sure how to fix this right now, and trying to make sense of this database with 0 android dev experience has already fried my brain a bit too much, but if anyone has pointers, i am down to come back to it and try and fix it.

opusforlife2 commented 4 months ago

Anyway, this can be fixed by adding a clause to the ORDER BY of some SQL query, in case someone wants to solve it.

@ajgae Did this not work?

ajgae commented 4 months ago

Anyway, this can be fixed by adding a clause to the ORDER BY of some SQL query, in case someone wants to solve it.

@ajgae Did this not work?

@opusforlife2 i did not look at the queries in detail as i spent a lot of time trying to understand the codebase better mostly, but a couple of clues are leading me to think that the culprit is not the queries themselves, but rather the merge logic:

here's the video to demonstrate: https://github.com/TeamNewPipe/NewPipe/assets/69397914/5c581c1f-27e6-4a32-8266-123bc8362c93

the most confusing part about this is that only remote playlists autogenerated by youtube seem to be affected. what do you think?

ajgae commented 4 months ago

i am also realizing now that i got so caught up with the code i didnt read the initial issue properly. this should probably be its own issue, since it is not about the ordering of playlists in the add to playlist fragment but rather in the bookmarks fragment. i can open a new one if youd like.

opusforlife2 commented 4 months ago

@ajgae Thanks, yeah, that would be appropriate. I'll mark the comments here as off-topic, but you can copy the content for your own issue where needed.

GfEW commented 4 months ago

@Monstanner

The issue can be closed.

@Stypox

only right after upgrading to 0.27.0, so I wouldn't worry about it. It's ok that the order is not updated when querying playlists, but only when doing something with them.

Whilst that conclusion feels reasonable from the perspective of github folks and power users, I don't think it aligns very well with the reality of not-so-techy end users who appreciate NewPipe for their everyday yt endeavors and have learned how to use it, but e. g. wouldn't file bug reports - for the following reasons:

1. Who's affected: If this bug reproducibly shows up by the upgrade to 0.27.0, this means the entire userbase runs into it, with the exception of only those who don't upgrade to 0.27.0, or accidentally rearrange playlists before their next use of "add to playlist".

2. How severely affected: There are more severe bugs for sure, but if your collection of playlists has grown into the dozens, the messed-up order is a real nuisance every time you wish to playlist a new medium.

3. How easy to overcome: If you've never faced a need to rearrange playlists (because they've always been in consistent alphabetical order on their own), it's far from obvious how the sudden mess-up in the "add to playlist" dialog can be fixed. 3.1. In the "add to playlist" dialog, there is no button to switch sorting back to alphabetical (or to any other sorting mode), nor are there handles that would allow manual rearrangment. 3.2. In the playlist tab (where you could solve the problem if you knew), the problem doesn't even exist. Why should it be relevant to the bug? The suggested "hidden solution" by rearranging a listing that already is in perfect alphabetical order, in order to fix a different listing elsewhere that is not, doesn't make a lot of common sense.

Anyway, this can be fixed by adding a clause to the ORDER BY of some SQL query, in case someone wants to solve it.

Although I'm able to contribute to github issues (which already separates me from the majority of NewPipe users I know), I'm not a coder, hence left hoping for someone more technically adept to take care of the code side of things.

Given the above reasons, would it be appropriate to reopen this issue, or am I totally off the road?

illustribe commented 3 months ago

It's also happening to me. It's annoying since the order of the playlists in the preview seems completely random, so one has to go through all the names to find the intended one... A big nuisance when adding many items to different playlists in a row.

Edit: @Monstanner is right and after rearranging any one playlist the order gets fixed again. Thanks!