BUG: Widgets bar and slider min/max values are limited by widget width

I’m using LVGL9.3 but master #10009 is affected too. I use slider widget to seek in music file with millisecond precision. One of files that I tested has 180 minutes of audio data (so slider range was from 0 up to about 10800000 milliseconds). Slider width is about 600px. When I set value higher than about 4020000 I noticed that knob and bar moved to start (rolled over). I started looking what causing issue, due to 4 millions are within int32 and found quite a lot of lines of code with multiplication of int32 values without widening to int64.

In slider.c # 10009 widget issue may happen at least in lines: 605 and 624.
In bar.c # 10009 widget issue may happen at least in lines 436 - 463 where ever multiplication happening between geometry and values.

For example slider.c line 605 original:
new_value = (new_value * range + indic_w / 2) / indic_w;
I fixed in my project like:
new_value = (uint32_t)(((uint64_t)new_value * (uint64_t)range + (uint64_t)(indic_w / 2)) / indic_w);

In bar.c line 462 original:
anim_cur_value_x = (int32_t)((int32_t)anim_length * (bar->cur_value - bar->min_value)) / range;
I fixed in my project like:
anim_cur_value_x = (int32_t)(((int64_t)anim_length * (int64_t)(bar->cur_value - bar->min_value)) / (int64_t)range);

EDITED: text changed to represent issue more accurately.

Hi @Rostic,

I strongly recommend you open an issue in the LVGL Open repo. Your description is clear, but if you add more input, such as videos, images, logs, and a simple reproduction. This will be super helpful.

Check this link:

1 Like

I created issue: https://github.com/lvgl/lvgl/issues/10308
Text of original post updated/changed to represent issue more accurately.

Ooops, that actually create new issue, due to all values expected to be signed so better fix have to be like this:
new_value = (int32_t)(((int64_t)new_value * (int64_t)range + (int64_t)(indic_w / 2)) / indic_w);
All unsigned type conversions changed to signed.