Open Bug 1511852 Opened 6 years ago Updated 2 years ago

"clear downloads" locks the UI

Categories

(Firefox :: Downloads Panel, defect, P3)

65 Branch
defect

Tracking

()

People

(Reporter: pomax, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0

Steps to reproduce:

It appears that "clear downloads" runs in O(n) on the UI thread, rather than running in a background thread with intermittent syncing of the dialog on the process made - not an every day problem, but when you've just used Firefox to download 38k files from freemusicarchive because it was about to disappear forever, and you then want to tell firefox to clear its download history, things go rather wrong.



Actual results:

Two things happen:

1. the UI locks up. Not just "becomes sluggish", it plain old locks up. 
2. After 30 seconds, you get the "a script is running slowly" with a stop/continue, but neither button actually registers because the UI thread is _still_ locked up.


Expected results:

Instead, this should have run in O(1), with the UI presenting an empty list immediately, while sqlite gets issued "BEGIN TRANSACTION; DROP TABLE downloads; CREATE TABLE downloads (...); COMMIT;", which runs in constant time, and almost always faster than the time necessary to resolve even a small number of DELETE instructions.
I couldn't reproduce as I don't have access to a download history with "38k files".

Assigning a component to get an opinion on this.
Component: Untriaged → Downloads Panel

Are you clearing downloads from the Library window?

Flags: needinfo?(pomax)
Depends on: 734643

Yeah, library window -> right click on any of the entries -> "clear Downloads".

Of course you don't need tens of thousands, you'll see a timing difference between "1" and "100", too, it'll just be smaller. Easy enough to rack up 100 downloads by hitting up reddit.com/r/redpandas or something, scrolling until there's a few pages worth of links, and just bulk-downloading all the <img> sources with something like:

 Array.from(document.querySelectorAll('img'))
  .forEach(img => {
    let a = document.createElement('a');
    a.href = img.src;
    a.download = (new URL(img.src).pathname.substring(1));
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
  });
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(pomax)
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.