Bug 390748 - Deleting a file freezes dolphin UI during the deletion
Summary: Deleting a file freezes dolphin UI during the deletion
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.43.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-19 18:29 UTC by Méven Car
Modified: 2019-11-14 08:35 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.65


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Méven Car 2018-02-19 18:29:54 UTC
Step to reproduce

1. Select a 1 Go file (or any file that you take more than 1 second to delete on your drive)
2. Hit shift-del
3. confirm.

Actual Result:

Dolphin UI hangs until the file is deleted. The confirmation window can stay open while the UI is frozen.

Expected Result:

Dolphin UI is responsive.


I believe the bug is in fact in KIO::DeleteJob around lines :

            // Normal deletion
            // If local file, try do it directly
            if ((*it).isLocalFile() && QFile::remove((*it).toLocalFile())) {
                qDebug() << "DeleteJobPrivate::deleteNextFile isLocalFile" << QDateTime::currentDateTime();
                job = nullptr;
                m_processedFiles++;
                if (m_processedFiles % 300 == 1 || m_totalFilesDirs < 300) {  // update progress info every 300 files
                    m_currentURL = *it;
                    slotReport();
                }
            } else {
                // if remote - or if unlink() failed (we'll use the job's error handling in that case)
                // qDebug() << "calling file_delete on" << *it;
                if (isHttpProtocol(it->scheme())) {
                    job = KIO::http_delete(*it, KIO::HideProgressInfo);
                } else {
                    job = KIO::file_delete(*it, KIO::HideProgressInfo);
                    job->setParentJob(q);
                }
                Scheduler::setJobPriority(job, 1);
                m_currentURL = (*it);
            }


It makes deletion synchronous by default for any local file.
Any slow device or big files will cause the UI to freeze.

A workaround I have tested with success is removing the localFile fast-path:
            // Normal deletion
            // If local file, try do it directly
            if ((*it).isLocalFile() && QFile::remove((*it).toLocalFile())) {
                qDebug() << "DeleteJobPrivate::deleteNextFile isLocalFile" << QDateTime::currentDateTime();
                job = nullptr;
                m_processedFiles++;
                if (m_processedFiles % 300 == 1 || m_totalFilesDirs < 300) {  // update progress info every 300 files
                    m_currentURL = *it;
                    slotReport();
                }
            } else {

It could be nice to mark the files in the UI as gray or give a some feedback that the file is being deleted.




Could be related to:
https://bugs.kde.org/show_bug.cgi?id=389807
https://bugs.kde.org/show_bug.cgi?id=382779
https://bugs.kde.org/show_bug.cgi?id=380250
Comment 1 Nate Graham 2018-02-19 22:55:10 UTC
Thanks for the high-quality bug report! Would you be interested in producing a patch for this issue?
Comment 2 Méven Car 2018-02-19 23:31:24 UTC
I am indeed. I will start tomorrow probably.
My workaround could be a start, but I need to do some tests to avoid regression and keep a good user experience.
It might require some UI work in dolphin to make it clear that a file is being deleted.
Otherwise If a user removes a big file, he will only notice that it worked when the deletion completes and the file disappear in the UI.
Comment 3 Kai Uwe Broulik 2018-02-20 08:58:21 UTC
Re-assigning KIO where deletejob lives
Comment 4 Méven Car 2018-09-30 09:57:23 UTC
Seems related to https://bugs.kde.org/show_bug.cgi?id=358231

I know from seeing the code that copying has the same issue as deletion : it is synchronous.
I guess moving files is also affected. It uses DirectCopyJob for local files which will hang the app for as long as the copy is going on.
Comment 5 Mahendra Tallur 2018-10-19 12:50:52 UTC
I've just opened this bug which might be related : https://bugs.kde.org/show_bug.cgi?id=400025
Comment 6 Méven Car 2019-03-07 09:48:26 UTC
Related to https://bugs.kde.org/show_bug.cgi?id=358231
Comment 7 Méven Car 2019-11-14 08:35:34 UTC
Git commit 80d5f52b0675912b1522209746357c41742fe611 by Méven Car.
Committed on 14/11/2019 at 08:35.
Pushed by meven into branch 'master'.

[DeleteJob] Use a separate worker thread to run actual IO operation

Summary:
FIXED-IN: 5.65

Reviewers: dfaure, #frameworks

Reviewed By: dfaure

Subscribers: kde-frameworks-devel

Tags: #frameworks

Maniphest Tasks: T11627

Differential Revision: https://phabricator.kde.org/D24962

M  +176  -72   src/core/deletejob.cpp

https://commits.kde.org/kio/80d5f52b0675912b1522209746357c41742fe611