minbrowser / min

A fast, minimal browser that protects your privacy
https://minbrowser.org/
Apache License 2.0
7.95k stars 703 forks source link

Any way to make Min a bit more lightweight ? Or a lightweight version with less features ? #1348

Open PEPERSO opened 3 years ago

PEPERSO commented 3 years ago

Hello !

I love Min in every way I use it, the only issue is that it is quite heavy on the system : on start up, without any tab openned, it takes about 650Mo of RAM... Do you think there could be a lightweight version ? Or in the first place, do you have advices to make it lighter, or any personnal configuration I could set to save some RAM ?

Thanks anyway ! :1st_place_medal:

PalmerAL commented 3 years ago

That seems higher than expected; if I try the same thing (on macOS) I get about 160mb. Can you get a breakdown of the memory usage by process (you should see a "Min" process and some "Min helper" ones)?

PEPERSO commented 3 years ago

Before opening Min, I had run clearhistory, deleted all tabs and tasks, then I close it, wait for the process to end, then restart it. From gnome-system-monitor, I get: min-memory

But I am glad to know that it should be less :) Any hints on this ?

Syndamia commented 3 years ago

I also usually experience around 500-600MB of RAM usage. I use Linux Mint 20, so my guess is it has something to do with Ubuntu or maybe even Debian.

Also, on my desktop (also running Linux Mint 20) very rarely Min would start consuming all of the RAM and swap memory and render it unusable. Though, this should be taken with a grain of salt, because the installation was kind of scuffed at the time (I recently reinstalled) and the hardware is less than ideal.

PalmerAL commented 3 years ago

I tried it on Ubuntu as well, and I got about 150mb, so it's interesting that it's so much higher for you.

If you go to developer > inspect browser > memory, you can take a snapshot and export it; that should show if there's an issue with our code. You can do the same thing with the main process as well if you launch min with --inspect-8080 and connect to it from Chrome.

Syndamia commented 3 years ago

I took a snapshot but I really have no clue how to interpret it, maybe you can (added .txt at the end so I can directly upload it): [Deleted]

PalmerAL commented 3 years ago

I deleted the file you linked from your comment because it turned out to include a copy of your open tabs in it; sorry for not realizing that earlier. Anyway, that profile shows barely any memory usage coming from our JS code, so the high memory usage in the renderer process at least is probably coming from somewhere in Electron or Chromium (meaning there isn't much we can do about it).

It's possible to get a similar report for the main process if you start min with `--inspect, and then launch chrome, go to chrome:inspect, and open the memory tab in the devtools. I'm not sure how much that's going to show either, though, because it has the same limitation as the report in the renderer process - it only shows our code, and not Electron's. (It's probably best to do that with a blank profile to avoid the same issue with including personal information).

If the issue is in Electron, then I guess we'd need to look at how debugging memory usage in native apps usually works. That's not something I've done before, so I don't have much idea how to do that, but I'm sure it's possible.

Syndamia commented 3 years ago

I swear I looked for any personal information ... thanks for removing it!

Anyway, I did the --inspect thing on a brand new virtual machine of Linux Mint 20, this is the result: Heap-20201121T131333.heapsnapshot.zip

PalmerAL commented 3 years ago

Thanks for trying that. Unfortunately that doesn't show much either - 14mb of memory usage total, 10mb of which is the content blocking filter list (which is about what I would expect). So whatever issue there is is most likely something in Electron rather than Min specifically. (The snapshot was taken when the memory usage was high, right?)

Other than that, I don't have any immediate ideas.

Syndamia commented 3 years ago

The snapshot was taken when the memory usage was high, right?

Yeah, the memory usage was around 350-400 MB, and I only had a single tab (YouTube).

Also, I found this post, this seems to be an electron issue (the screenshot looks like something from a Linux distro) but I don't think anyone really knows what causes it.

PEPERSO commented 3 years ago

Maybre I'll try to build Min myself, to see if it changes if the .deb is made on a ubuntu machine... Do you think it could have an impact ?

Syndamia commented 3 years ago

I don't think it will make a difference, if you just run the source on your local machine (with npm), it still consumes the same amount of memory. Also, a bit before 1.17.1 was released, I built it myself and installed the update on my machine and I don't remember it making a difference (although, take this with a big grain of salt, I didn't take note of the memory usage at the time).

PEPERSO commented 3 years ago

Well, at first I had less than 200Mo on the welcome page, but it went back to the usual 600Mo after a while... I really hoped it was done, but nope...

Yeah, the memory usage was around 350-400 MB, and I only had a single tab (YouTube).

You're luckier than me, it never gets below 500Mo for me...

Milo123459 commented 3 years ago

Windows with 5 tabs open I get 200 mb, weird..

PEPERSO commented 3 years ago

Windows with 5 tabs open I get 200 mb, weird..

Yeah, I've tried it on Manjaro, Trisquel, Windows, it is always much more lightweight (150-300Mo) than it is on my Lubuntu main system (600Mo) :disappointed:

Syndamia commented 3 years ago

Yeah, on Linux Mint (and maybe Lubuntu? haven't tested) there seems to be a pretty big Electron memory leak issue. For example, Rambox also leaks memory like crazy (although Discord has normal RAM usage).

If you have 16GB of RAM, you should be, in general, fine, but anything less and you could have major issues. The only "workaround" I've found is just not using these distros, as dumb as it sounds.

PEPERSO commented 3 years ago

Yeah but I'm on Lubuntu because I have only 4Gb RAM... But I'll keep with it, it's perfect except for this, infortunately

Milo123459 commented 3 years ago

Also, whenever you open a chromium based app (ie electron apps) it always takes up a lot of memory / cpu once started up, then goes into an idle mode after a while where're everything is kind of cached, making the footprint a lot "less"

Syndamia commented 3 years ago

But I'll keep with it, it's perfect except for this, infortunately

Yeah, I'm in the same boat. Min on my desktop is still causing me issues, mainly with it starting to consume all of my RAM, rendering the PC unusable. On my laptop it doesn't cause me issues, so I'll still use it there.

I've even switched distros, to Fedora, and the issue still persists. I thought it was Microsoft Teams, but it isn't, I have no idea what causes it. The only thing that might be a reasonable cause is sleeping (although I sleep my laptop even more often, and there are no problems). I don't think it has ever happened, before putting the computer to sleep, at least once after the launch of Min.

PEPERSO commented 3 years ago

Semi good news: I reinstalled lubuntu OS using ubuntu mini.iso, and with only lubuntu-core installed, min worked perfectly, and with 150-200MB RAM, as expected. But then, since only lubuntu-core would a bit tough, I installed other programs, and now Min is back to the 650MB it use to take on Lubuntu. So maybe I'll try to see what happenned in a VM someday, it is probably a dependency that was raplaced by another program, taking too much ram... :detective:

It shows how much we love Min that we even changed OS for it :smile:

PalmerAL commented 3 years ago

That's really interesting; if you do get a chance at some point to see which package is causing it that would be very helpful. But no worries if you can't.

If I get a hard drive soon (story), I'll try installing lubuntu and see if I can reproduce it.

PEPERSO commented 3 years ago

I'll try, but it will be in a week probably

If I get a hard drive soon (story), I'll try installing lubuntu and see if I can reproduce it.

I can't follow your link, it asks for a discord password which I don't have. Remember, if you try it, to use a netinstall, with a ubuntu mini.iso, not normal lubuntu install. I followed these steps, and run sudo apt install lubuntu-corein tty, instead of installing ubuntu unity as they do in the tuto. Then, install min from a 1.17 .deb I had downloaded before.

I'll tell you if I find something :)

Syndamia commented 3 years ago

I can't follow your link, it asks for a discord password which I don't have.

It's a link to a message in the Min Discord server

PEPERSO commented 3 years ago

Just to say, I've installed Lubuntu from netboot install in a VM, and I am currently writing this comment from Min 1.17.3, in this VM with less than 300MB of RAM allocated to Min.

I'll keep on investigating when I get some more time :)

PEPERSO commented 3 years ago

Hello, it's me back again ;) I am not completely sure, but this difference of resources required by Min could be caused by disabling networkd-dispatcher.service I installed Lubuntu 20.04 recently, had really low resources allocated to min, and here's what happenned:

  1. I tweaked some things in my OS (which is why I am not completely sure)
  2. Disabled this service
  3. Did a few other things not really related to internet

and then got, as before, 400 MB allocated to Min. Now I reinstalled Xubuntu 20.04, and I am back to the usual 150 MB required... I know it's a bit vague, I am just giving a few ideas in cas it can be useful.

Thanks for all your time and efforts anyway :) :1st_place_medal:

Syndamia commented 3 years ago

I'm fairly convinced that it's an electron/Linux problem and not a Min problem.

I just did a small test, on Ubuntu 20.04 LTS, where I created a small "Hello World" electron application. After building and running it, it's consumes about 440 MB of RAM, and it's just a plain old "Hello World".

If you want to test it out for yourself, download and unarchive this, then inside the dist folder, you're gonna find an AppImage, run it (or alternatively, just build the whole thing with yarn dist).

Should this issue be closed?