-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Improve UI responsiveness during RSS downloading. Closes #873, #1089, #1235, #5423 #6176
Conversation
, qbittorrent#1089, qbittorrent#1235, qbittorrent#5423. --HG-- branch : magao-dev
@@ -116,6 +119,8 @@ namespace Rss | |||
bool m_dirty; | |||
bool m_inErrorState; | |||
bool m_loading; | |||
QAtomicInt m_DeferredDownloadCounter; | |||
QList<ArticlePtr> m_DeferredDownloads; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lower case d in m_deferredDownloads
and the one above it please.
Why? All the complications with timers and partial processing create quite a depressing impression... |
My Qt knowledge is very limited (prior to embarking on these changes it was zero), and the information online is pretty contradictory regarding QThread. And looking at issue #1235 there is already a fair amount of confusion on this. I had an initial attempt at using QThread, and thought I'd implemented it correctly, but it didn't give any improvement and adding some debug logging revealed that everything was still running on the main thread. At which point I came to the conclusion that it would require someone with much better knowledge of QThread than I have to do it correctly, and went with an approach which - while ugly - actually worked. |
Rebased on top of #6212 and uncrustified. |
You may use |
I believe it's the interaction of threads, signals and slots that is the problem, and what I couldn't get right. I suspect that using QThread would be a requirement for that. Plus QThread is already in use for the RSS feed parsing. Given that I have a solution that is working well enough for me, I don't have the desire (or time) to investigate a different approach that I've already failed at. If the pull request isn't accepted, I'll just continue to use it in my own fork, and everyone else will have to continue with the current behaviour (frozen UI) unless someone else steps up with an alternative. |
Yes - this will benefit from those tips. There are 2 cases to deal with:
So what I've done is made it so that we only process a single article before allowing UI and other events to progress, then process the next article, etc. |
Hmm, then that means that in the future we should cache those signals and delay them. Then have the appropriate UI element ask the backend(after application startup): "hey I have finished starting up. Do you have feeds parsed/updated? Give them to me in one go". |
That approach would still result in a UI freeze while the articles are being processed, it would just happen later. The only methods I can see that won't result in a UI freeze is to either:
|
Just to clarify, I am not expecting YOU do it now. Just polish up this PR according to my other comments. This PR is a quick fix. |
@sledgehammer999 Rebased on top of master. Reworked to use single QTimer for all feeds, dispatched via Rss::Manager (otherwise having lots of feeds update at once could cause minor UI freezes). |
Rebased on top of master. |
Thx. I hope that this works as intended. I am not an RSS user so I can't fully test it. |
This is one of a series of pull requests designed to improve the responsiveness of the UI. This pull request addresses #873, #1089, #1235, #5423 (which are all essentially the same issue reported multiple times).
The issues mentioned talk about using QThread, and my initial intention was to move the processing of the RSS articles fully to the thread currently being used for RSS parsing, but I wasn't able to work out how to get it to work. I have taken a different approach in this pull request - process a single article, then fire a timer to process the next article with a 1ms delay. This allows UI and input events to be processed almost immediately instead of the entire UI freezing until the feed is processed.
Note: Qt seems to do something special with a 0ms delay - I'm guessing adding it to the current events to be processed rather than actually going around the event loop - which resulted in a much less responsive UI than using 1ms.
This pull request also improves startup time, since the feeds were being processed before the UI was displayed. With this change qBittorrent is usable within a short period (~20 seconds in the VM on my QNAP) instead of having to wait for the feed processing (which took multiple minutes in my VM).