bluerobotics / cockpit

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

Map widget has a huge impact in performance #936

Closed rafaellehmkuhl closed 4 months ago

rafaellehmkuhl commented 5 months ago

Looking at Chrome's performance profile, it seems like VueLeaflet, which is used in the Map widget, is updating the markers (icons) in the map at every frame.

Looking at the resources usage, a clean Cockpit profile uses about 9% CPU on average. Adding Compass and VirtualHorizon don't seen to increase that by more than 2% in total. Adding the Map widget elevates that to an average of 67%, and that does not drop with time. Removing the Map widget gets Cockpit to normal levels again. In comparison, the VideoPlayer widget, which one would think could be more expensive, increases the CPU usage by about 6% on average, and about 5% more on GPU.

The default ROV profile for Cockpit uses an average of 84% CPU here by default. It does not matter if I'm looking at the Video view or the Map view (remember both are being rendered nonetheless). If I remove the Map widget, that drops to about 21%.

All tests were conducted on a Mac M1 2020 16GB.

An idea to solve that would be to move to the raw Leaflet library, instead of using VueLeaflet, as we are doing in the Mission Planning part. Codewise it's also good, as we use the same approach, can reuse code, and do not depend on a library in the middle, that does not expose the entire Leaflet API and also has performance downsides.