oae / gnome-shell-pano

Next-gen Clipboard Manager for Gnome Shell
https://extensions.gnome.org/extension/5278/pano/
GNU General Public License v2.0
1k stars 53 forks source link

Pano downloads files from copied URLs and freezes the UI for a while after the download #188

Open busybox11 opened 1 year ago

busybox11 commented 1 year ago

Description

What is the bug?

Problem Explanation

The bug happens when you copy the URL to a direct file download target.

Pano will download the entirety of the file, and right after doing it, it will freeze the entire UI for a while. I'm assuming this is a parsing state, but the preview in the history stays ONLY the URL, not the file preview.

Expected Behavior

A clear and concise description of what you expected to happen, and how the actual outcome differs:

Reprodution

How one can find the bug?

Steps To Reproduce

Steps to reproduce, if applicable:

  1. Open GNOME system monitor BEFORE downloading
  2. Copy a link to a file (example: http://ipv4.download.thinkbroadband.com/512MB.zip - 512MB file)
  3. Observe network interface download speeds to rise as soon as you copied the link
  4. GNOME should freeze as soon as the file is finished downloading, which you will notice as soon as it unfreezes, because the network speeds will be back to normal and one CPU core will be at 100% while it freezes.

Details

Mark with [ ] all that applies:

It happens with any application?

It happens only on one computer?

It happens only with some specific gnome configuration?

It happens only with some specific extension installed?

Diagnostics

Under what conditions does it happen?

Should only occur when Link previews is turned on in settings.

Environment

Screenshots

If applicable, add screenshots to help explain your problem:

Screenshot from 2023-04-30 22-59-16

Network speeds rising to 50MB/s for a ~500MB file, CPU core @100% as soon as it finishes. GNOME unfreezed and I took the capture.

image

Still shows up as a link in the history, no matter what file it is - tested with a valid ZIP file and test PNG file, hidden for privacy reasons.

ttmx commented 1 year ago

This gets stuck in src/utils/linkParser.ts, in the p.write(data) line, about line 107. It attempts to parse the file you give it as html, which is very slow for a 1GB file. This is imperfectly but trivially fixed by only p.writing the first 10000 or so characters of the file, this is always instant, and I cannot find websites that don't have their meta tags in the first 10000 characters.

Would it be possible to merge request?

busybox11 commented 11 months ago

@ttmx I guess you could do a merge request, yeah. Maybe even a fork - this extension does not seem to be supported anymore. I'd love to use your changes, though I don't really have much time to tinker with it and debug the extension.

Maybe a better solution would be to use a separated single thread that will return the extension's preview contents once it's loaded? This won't fix the full file download issue, but it would improve the overall experience.

BLKFSH commented 7 months ago

I just faced the same issue. I was very confused when out of nowhere my network usage spiked and then my whole OS froze. It would be nice to see this fixed, maybe by querying the type of response first and only accepting HTML, images and the like and of course having a size limit so you don't try and download a 1GB file for a preview. It would be interesting to know how for example Discord handles link previews since they don't have this issue (see below, first link is a file that gets downloaded by the extension, but Discord is smart enough not to do that and only show the preview for the second link which responds with HTTPS/has a preview image in the metadata): image For now I guess I'll keep the link preview disabled which sucks because it's a cool feature!