mullvad / mullvadvpn-app

The Mullvad VPN client app for desktop and mobile
https://mullvad.net/
GNU General Public License v3.0
4.89k stars 335 forks source link

The memory usage issue #2431

Closed lessneek closed 3 years ago

lessneek commented 3 years ago

Issue report

Operating system: Manjaro 20.2.1 Nibia

App version: 2020.7

Issue description

The app unnecessary uses __A_LOT__ of memory:

image that is the issue.

Before app launch: Screenshot-20210202130000-116x28 After app launch: Screenshot-20210202130013-116x26

P.S. Developers, please, don't use an electron for every little small service app. The good text about the topic: https://tonsky.me/blog/disenchantment/ There are a lot of good technologies which allow you to make a great app with small memory usage. For example telegram-desktop, it uses only 250MB but it consists of many great gui elements: image

BTW: thank you for the great service.

faern commented 3 years ago

It is indeed possible to write native UIs using the platform's preferred UI toolkit and end up with very small and efficient frontends. It's also possible to do something semi-cross platform with things like Qt (I think this is what telegram-desktop uses?).

The reason why we went with Electron is that back in the day when we started developing this app, the Mullvad app team was way smaller. If we were going to realistically ever complete the backend and security aspects of it we had to use the fastest approach for the frontend. And we had web dev skills on the team and zero Qt or other UI toolkit knowledge. So that kind of left us with only one option.

A vague dream of mine is to eventually replace it with something native on at least a subset of the platforms. But that's currently not on any specified roadmap. Another alternative, that we look at a bit more realistically, is to make our own custom build of Chromium+Electron. That way we can hopefully slim it down substantially. But this is also yet unexplored territory.

As another option, you always have the CLI available. So you technically don't have to run our electron frontentd to use our VPN tunnel. This guide is not complete, but can get you started: https://mullvad.net/en/help/how-use-mullvad-cli/

pinkisemils commented 3 years ago

Comparing to Telegram's desktop client isn't ideal, both electron apps and Telegram's desktop client have issues with holding on to memory forever - cycling through a single channel that has posts images exclusively for some seconds easily got me to 1398 megabytes of memory usage. I don't believe our app will ever get that bad. Of course, the steady state of a new instance uses significantly less memory. Screenshot from 2021-02-09 22-50-39

We have also considered just optimizing our UI code to decrease memory use, but so far the tooling has not been great.

faern commented 3 years ago

Closing since the issue itself does not tracking anything that is actually going to change in any foreseeable future.

bloodyeyesblackblood commented 2 years ago

It is indeed possible to write native UIs using the platform's preferred UI toolkit and end up with very small and efficient frontends. It's also possible to do something semi-cross platform with things like Qt (I think this is what telegram-desktop uses?).

The reason why we went with Electron is that back in the day when we started developing this app, the Mullvad app team was way smaller. If we were going to realistically ever complete the backend and security aspects of it we had to use the fastest approach for the frontend. And we had web dev skills on the team and zero Qt or other UI toolkit knowledge. So that kind of left us with only one option.

A vague dream of mine is to eventually replace it with something native on at least a subset of the platforms. But that's currently not on any specified roadmap. Another alternative, that we look at a bit more realistically, is to make our own custom build of Chromium+Electron. That way we can hopefully slim it down substantially. But this is also yet unexplored territory.

As another option, you always have the CLI available. So you technically don't have to run our electron frontentd to use our VPN tunnel. This guide is not complete, but can get you started: https://mullvad.net/en/help/how-use-mullvad-cli/

I would like to have the App in something like C.. but well, the devs shouldn't need to learn something new or feel stressed by to do so.

So well how 'bout Tauri? It's an absolute lighweight solution to Electron. there could be a little problem, since it uses the Native Web Render, so there could be different designs in differnet OS.. But its a dozen times less ressource hungry than any Electron based app

Con: it's still JavaScript and uses much more memory and so on than a proper App made in other Languages. Pro: it's still JavaScript 'n ya as a Team didn't need to learn something new while it is lighter than a Elecetron App

pronebird commented 1 year ago

@bloodyeyesblackblood the devil is in details. I think it would take a substantial amount of time to migrate to Tauri even assuming there is a tremendous benefit in doing so and it's the best alternative today. As @faern noted, the vague dream is to build a native frontend for each platform. In the meantime, if we ever get to it, we could slim down electron to improve the memory footprint. This should keep everything else intact.