bluerobotics / cockpit

An intuitive and customizable cross-platform ground control station for remote vehicles of all types.
https://blueos.cloud/cockpit/docs
Other
72 stars 22 forks source link

Seek and destroy main memory leak #1444

Closed rafaellehmkuhl closed 1 day ago

rafaellehmkuhl commented 1 week ago

I performed about a week of testing with Cockpit to learn more about its performance issues.

A detailed report can be found here, but I will make a resume below.

The main leak

I could find that we indeed have a big memory leak that causes the application to become slow after about 20 minutes and to crash after around an hour (depending on the computer specs). After a lot of tests I could determine that this leak is caused by a v-tooltip component that is used in the expanded list of the Alerter.vue widget. This component is instantiated for every alert in the list, and is never garbage-collected, so for every new alert added to the list, a series of zombie components are created and left there forever. This PR replaces that component, effectively removing the main memory leak.

Before:

alerter-with-v-tooltip

After:

alerter-without-v-tooltip

Other leaks

I could also find that we have smaller memory leaks (with unknown sources) that grow very slowly, without interfering in most (99%?) user sessions, and that we have a concentrated memory leak when the joystick configuration page is open.

Future work

This PR only fixes the main memory leak (from the Alerter.vue widget), but a following PR should be done fixing the problem in the joystick configuration page as well, as it affects every user that opens that view.

We should also eventually have a better solution than the title attribute to replace the buggy tooltip, as the attribute does not work on mobile and takes a somewhat long hovering time to shown, degrading the UX.

Result

With this PR, the user can now effectively run Cockpit for hours without it becoming slow or crashing.