cryptee / web-client

Cryptee's web client source code for all platforms.
https://crypt.ee
Other
445 stars 22 forks source link

[Bug] High CPU usage after uploads to Photos #180

Closed pabloscloud closed 1 year ago

pabloscloud commented 1 year ago

Describe the bug High CPU usage after video and photo upload after the lid was closed for several minutes causing mac to hang.

To Reproduce Steps I took. Might not actually cause the problem for you.

  1. Go to cryptee photos
  2. Upload a few GB of photos and videos
  3. Close the lid
  4. See error

Expected behavior Either reload on high cpu usage or an error message of some form. Ideally this wouldn't happen.

Screenshots

Screenshot 2023-01-29 at 14 47 44 Screenshot 2023-01-29 at 14 48 48

System Information (please complete the following information):

Additional context Just ask. I'm a bit unsure of what informations could be helpful or are needed

johnozbay commented 1 year ago

Hi there! Thanks for filing this, and sorry you got hit with a strange CPU hungry issue.

So that I can understand the situation and the timeline of events better, a couple of questions.

Since it would be impossible to take the screenshot while the lid is closed (or while the computer is asleep), I'm guessing you took these screenshots after you woke the computer back up is this correct?

OR are you referring to using your computer in clamshell mode?


Also, it looks like both your browser and your operating system are beta. There could be a thousand reasons why the combination of these two could be causing the issues you're experiencing. Reason why this matters a lot is because DDG's browser is WebKit based, it uses the built in browser engine that comes shipped with the operating system. (in this case it's the beta one) and DDG's browser itself is in beta as well, so there may be incompatibilities between the two causing tons of unforeseeable issues.

As far as I can tell form the errors in your browser's console, what happened is that the browser kept trying to load the thumbnails, despite your computer pretending to be asleep, but since it had no internet while asleep, it couldn't load them.

Alternatively, it had the image in its cache, but it couldn't decrypt or load them into the DOM, because the computer was asleep and browser wasn't allowed to run heavy computational operations in the service worker.


One test you can run is trying exactly the same scenario in Safari, and taking exactly the same steps to see if it happens there or not. Since both DDG and Safari use WebKit this would help us figure out if this is a DDG issue or WebKit issue in general. Then we can run the test with Safari and follow the exact same steps with a MBAir M1 here but this time with a non-beta OS X version to see if it happens there. It's the closest we can get to a near-imperfect test to see if this is caused by one of the betas or not.


In general, as a rule of thumb, neither Cryptee nor any browser tab should be able to destroy and consume your device's CPU or memory, it should be automatically killed by your browser. i.e. chrome shows this :

image

and safari shows something like this :

image

So it sounds a lot like either DDG or WebKit on OSX beta is not sleeping the process when the device goes to sleep.

If these sound about right in general, then I'm afraid the best advice I can give at the moment is to not use the beta browsers while the browser teams address the underlying issue. (and we can help you file bug reports with either DDG or WebKit)

johnozbay commented 1 year ago

Let me know the specific timeline and steps (and if you're referring to the clamshell mode though) — not that it should matter — but it would definitely help us identify the underlying problem and report the issues to the WebKit team or DDG better ✌🏻

Looking forward to hearing,

Many thanks once again!

pabloscloud commented 1 year ago

Since it would be impossible to take the screenshot while the lid is closed (or while the computer is asleep), I'm guessing you took these screenshots after you woke the computer back up is this correct?

exactly and I also waited a few minutes to see if this issue preserves and it did

but since it had no internet while asleep, it couldn't load them. Alternatively, it had the image in its cache, but it couldn't decrypt or load them into the DOM

afaik macOS keeps the connection alive so I guess it makes more sense it's a cache issue

One test you can run is trying exactly the same scenario in Safari

I will double check using both safari and firefox and make sure everything is out of beta if the issue is still present

Let me know the specific timeline and steps (and if you're referring to the clamshell mode though)

So I was uploading around 350 videos to cryptee photos and did no more than 5 at once to make sure everything get's uploaded (as I previously noticed when uploaded all at once some seemed to be missing and other showed up multiple times for some odd reason but I'll need to keep an eye on that before filing a bug report for that). After around 300 videos I reloaded the page and checked if everything is right and as it was. Therefore I continued with the rest and as I usually do just closed the lid so I could get myself some food. After I ate I came back and started Apple Music which was hanging and bugging around a lot so I checked in the Activity Monitor.app for any suspicious usage. After I noticed the high CPU usage I closed DDG manually (neither force closed nor stoped it using Activity Monitor).

pabloscloud commented 1 year ago

I tested it in Safari without updating the OS and I didn't have any issues. If this happens again, I'll reopen this gh issue oc.

johnozbay commented 1 year ago

Thanks for getting back with this! In the meantime we're also looking into what may have caused the issue in the first place and coding safe guards so that even if browsers have similar hiccups in the future, others won't experience issues.

pabloscloud commented 1 year ago

I have proof this is ddg's fault as github causes the same issue now in ddg:

Screenshot 2023-01-31 at 12 34 38
johnozbay commented 1 year ago

Ha! Thanks for catching this! I would assume that they're onto it then, sounds like a quite common and general problem about CPU / resource utilization in general.

Many thanks for digging deep into this! Deeply appreciate the time you took to help shed some light onto this.