victronenergy / gui-v2

Other
29 stars 10 forks source link

QuantityLabel numbers have odd sizing #890

Closed blammit closed 6 months ago

blammit commented 7 months ago

Reported issue from https://community.victronenergy.com/questions/265862/venus-os-v33010-available-for-testing.html: after some period of time, the gauge numbers on the Brief page are incorrectly sized. Issue goes away on reboot.

73101-2024-03-19-09-46-04

The numbers are images provided by DigitImageProvider, so the provider is returning images of the wrong size for some numbers.

Once an image is created, it will be cached by the engine, so if the image is wrong it will be reused until the cache is cleared; in this regard it makes sense that the issue cleared on reboot.

jpetrell commented 6 months ago

I haven't been able to reproduce the issue, but it is somehow related to the image provider architecture. Replaced the image provider approach now with a monospaced digit font, it should fix the reported issue, but also improve the performance when we get the Qt Quick digit layouting paths get replaced with the more light-weight and optimized Qt text rendering pipeline.

In particular it is good to avoid dynamic quick item creation caused by the Repeaters in the code that were responsible for constructing the digits. All the digit images got reconstructed if the number of digits on the quantity label changed (e.g. 99 -> 100 causes jump from 2 to 3 digits), which luckily doesn't happen that often in the usual case. The old approach did peak in the profiling results earlier on the Brief page, but Bea optimized the issue away as part for #929. One remaining performance issue was with the ListQuantityGroup, where any value update to the group of values reconstructed all the quantity labels, causing bursts where dozens of images got destroyed and recreated at once.