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

Selecting all songs in my collection and right clicking freezes strawberry #392

Open
NucleaPeon opened this issue Mar 24, 2020 · 5 comments · May be fixed by #729
Open

Selecting all songs in my collection and right clicking freezes strawberry #392

NucleaPeon opened this issue Mar 24, 2020 · 5 comments · May be fixed by #729
Assignees
Labels

Comments

@NucleaPeon
Copy link

Describe the bug
Strawberry freezes when using the context menu on thousands of selected items in the collections sidebar

To Reproduce

  1. Click into the collections sidebar
  2. Ctrl+A to select all
  3. Right click
  4. One cpu core at 100%
  5. ????
  6. Freeze (tested about a minute of waiting before closing)

Expected behavior
The context menu to pop up. It seems to be doing a lot of processing which I think is unneeded.
In my mind, if multiple items are selected, strawberry should understand that we are selecting multiples and have a right click menu specific for multiple item selection appear immediately, so we can click out of it and cancel the operation easily. If we select an item, then we should go full bore with the processing of thousands of artists/albums/songs. Perhaps a box to show loading and a cancel button that can be clicked because otherwise I have to close out strawberry forcefully.

Screenshots:
Screenshot_20200324_142249

System Information:

  • Operating system: Gentoo amd64, linux [hostname] 4.14.173 Can't make #1 SMP PREEMPT Fri Mar 13 13:47:54 PDT 2020 x86_64 Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz GenuineIntel GNU/Linux
  • Strawberry Version: Version 0.6.8-72-g89d96a3e AND Version 0.6.8-88-gafa8486d
@jonaski
Copy link
Member

jonaski commented Mar 30, 2020

There isn't an easy fix for this with the current model implementation as far as I can think of.
The reason it takes long is that the model uses lazy loading. Meaning it only loads the first node from SQL when the model is reset (on startup and on search) in the grouping (default the artist).
So when your right clicking it loads all the songs that aren't already loaded from SQL. It only loads the songs on right click to determine whether to show the "edit track" option (if a cue track is selected it won't show it), but it is still necessary to do that, and it's impossible to know before loading the rest of the songs how many songs are selected, since the grouping can be by genre for example it will only see a few nodes initially. Even if we move the song loading to when ie. "add to playlist" is selected it will still hang there if too many songs are selected, so that's just moving the problem, not fixing it.
The model could be changed to move away from lazy loading and use the backend for everything, but it would take much longer for the songs to load on startup, we will have to see how that affects a really huge collection. It's also a lot of work, and I don't know if there are other side-effects.
I think it's very rare that someone would add the entire collection to the playlist . In 10 years Clementine have existed I haven't seen any complaint or bug reports on this ever, so I'm a bit resistant to change it.

@NucleaPeon
Copy link
Author

Hmmmmm, then would it be possible for a right-click to do lazy loading in 'blocks' and if the user clicks outside (which would normally cause the right-click menu to disappear), it would cancel additional loading of blocks? The cursor could be set to a busy cursor to indicate that loading is occurring at that time.

@jonaski
Copy link
Member

jonaski commented Mar 30, 2020

The loading needs to be done in a different thread to solve it, so it needs to be moved to the backend or use a current thread, otherwise it won't work showing a loading indicator or respond to clicks, because the song loading blocks everything until it's finished.
The initial loading/search is done in concurrent threads, but that's one SQL query per reset, that's why it doesn't hang there, and why it works.
But the problem with the lazy loading is that when asking for all the songs under the first node it does it in one SQL query per node, that's the way it's implemented, so that won't work to do in concurrent threads as for as I can see.
I think it has to use the backend, then it can show a loading indicator and doesn't block, and can also be cancelled. But like I said, it's a bit work, basically have to rewrite half of the model.

@NucleaPeon
Copy link
Author

This is probably the lowest priority of issues you're dealing with right now. In fact, we can ignore it for now. If I'm the only one who's mentioned it for many years of clementine/strawberry development, it's not important enough. I can always try my hand at it if it bothers me enough, so I'll close the ticket. Thanks for the information and context.

@jonaski
Copy link
Member

jonaski commented Mar 14, 2021

I did some testing removing all the lazy loading stuff and changing to loading all songs in the model at startup.
There are both advantages and disadvantages with that approach, it will take longer for the program to start, at least until it is usable, since the model gets loaded with all the songs, this will freeze the program for a while, and that loading needs to be done in the main thread since it's GUI specific. It will also take longer to switch between group by's.
The advantages are that it fixes the problem you have here.
But it also fixes many other problems. There is a problem where the entire model needs to be reset if a song disappears from disk (a song that hasn't been fully loaded in the model so it can't know what nodes to remove), this is probably the most important reason I want to try make it work.
It also fixes problems with thumbnails in the collection getting stuck if you change a cover for a song that hasn't been fully loaded in the collection, since it can't know what cache key to remove in that case.

@jonaski jonaski reopened this Mar 14, 2021
@jonaski jonaski self-assigned this May 1, 2021
jonaski added a commit that referenced this issue Jun 27, 2021
jonaski added a commit that referenced this issue Jun 27, 2021
jonaski added a commit that referenced this issue Jun 27, 2021
@jonaski jonaski linked a pull request Jun 27, 2021 that will close this issue
jonaski added a commit that referenced this issue Jun 27, 2021
jonaski added a commit that referenced this issue Jul 1, 2021
jonaski added a commit that referenced this issue Jul 2, 2021
jonaski added a commit that referenced this issue Jul 11, 2021
jonaski added a commit that referenced this issue Jul 11, 2021
jonaski added a commit that referenced this issue Jul 12, 2021
jonaski added a commit that referenced this issue Jul 16, 2021
jonaski added a commit that referenced this issue Jul 21, 2021
@jonaski jonaski added bug and removed enhancement labels Jul 23, 2021
jonaski added a commit that referenced this issue Jul 23, 2021
jonaski added a commit that referenced this issue Jul 28, 2021
jonaski added a commit that referenced this issue Aug 1, 2021
jonaski added a commit that referenced this issue Aug 1, 2021
jonaski added a commit that referenced this issue Aug 14, 2021
jonaski added a commit that referenced this issue Aug 20, 2021
jonaski added a commit that referenced this issue Sep 9, 2021
jonaski added a commit that referenced this issue Sep 25, 2021
jonaski added a commit that referenced this issue Oct 7, 2021
jonaski added a commit that referenced this issue Oct 13, 2021
jonaski added a commit that referenced this issue Oct 14, 2021
jonaski added a commit that referenced this issue Oct 30, 2021
jonaski added a commit that referenced this issue Apr 14, 2022
jonaski added a commit that referenced this issue Apr 14, 2022
jonaski added a commit that referenced this issue Jun 10, 2022
jonaski added a commit that referenced this issue Jun 24, 2022
jonaski added a commit that referenced this issue Jul 26, 2022
jonaski added a commit that referenced this issue Aug 10, 2022
jonaski added a commit that referenced this issue Sep 23, 2022
jonaski added a commit that referenced this issue Oct 29, 2022
jonaski added a commit that referenced this issue Oct 31, 2023
jonaski added a commit that referenced this issue Nov 3, 2023
jonaski added a commit that referenced this issue Nov 15, 2023
jonaski added a commit that referenced this issue Apr 1, 2024
jonaski added a commit that referenced this issue Apr 9, 2024
jonaski added a commit that referenced this issue Apr 21, 2024
jonaski added a commit that referenced this issue Apr 21, 2024
jonaski added a commit that referenced this issue Apr 21, 2024
jonaski added a commit that referenced this issue Apr 21, 2024
jonaski added a commit that referenced this issue Apr 22, 2024
jonaski added a commit that referenced this issue Apr 23, 2024
jonaski added a commit that referenced this issue Apr 23, 2024
jonaski added a commit that referenced this issue Apr 23, 2024
jonaski added a commit that referenced this issue May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants