Repository navigation
Description
Summary
LV_PROPERTY_ID_TYPE2 extracts the wrong bits and LV_PROPERTY_ID_INDEX includes TYPE2 for paired properties
LVGL version
v9.6.0
Platform
ESP32 / ESP-IDF 6.1.0 embedded project, using C++.
Compiler: GCC (ESP-IDF toolchain).
Configuration:
LV_USE_OBJ_PROPERTY = 1
LV_USE_OBJ_PROPERTY_NAME = 1
What happened?
The property ID decoding macros appear to be inconsistent with the documented encoding of LV_PROPERTY_ID2.
According to the documentation:
-
LV_PROPERTY_ID: - Bits 31–28: property value type. - Bits 27–0: property index. -
LV_PROPERTY_ID2: - Bits 31–28: first argument type. - Bits 27–24: second argument type. - Bits 23–0: property index.
However, the current macros are:
#define LV_PROPERTY_ID_TYPE(id) ((id) >> LV_PROPERTY_TYPE_SHIFT)
#define LV_PROPERTY_ID_TYPE2(id) ((id) >> LV_PROPERTY_TYPE_SHIFT)
#define LV_PROPERTY_ID_INDEX(id) ((id) & 0xfffffff)LV_PROPERTY_ID_TYPE2 uses LV_PROPERTY_TYPE_SHIFT (28) instead of LV_PROPERTY_TYPE2_SHIFT (24), meaning it extracts the first argument type again rather than the second.
Additionally, LV_PROPERTY_ID_INDEX masks 28 bits, which includes the TYPE2 field for paired properties instead of extracting only bits 23–0.
I verified this at runtime using lv_obj_property_get_id() on actual LVGL widget instances.
The results were:
| Property | Encoded ID | Expected TYPE2 | Current TYPE2 | Correct TYPE2 |
|---|---|---|---|---|
| slider.value | 0x1B000800 | 11 | 1 | 11 |
| slider.left_value | 0x1B000801 | 11 | 1 | 11 |
| slider.range | 0x11000802 | 1 | 1 | 1 |
| animimage.src | 0x51000900 | 1 | 5 | 1 |
| roller.options | 0x71000600 | 1 | 7 | 1 |
| roller.selected | 0x11000601 | 1 | 1 | 1 |
I independently verified TYPE2 using:
#define MY_PROPERTY_ID_TYPE2(id) \
(((id) >> LV_PROPERTY_TYPE2_SHIFT) & 0x0F)This correctly extracts the second argument type for all six properties.
The existing index macro also produces incorrect results for paired properties:
slider.value:
LV_PROPERTY_ID_INDEX(id) = 0x0B000800
Expected paired index = 0x000800
What did you expect to happen?
The decoding macros should follow the documented bit layout.
For example:
#define LV_PROPERTY_ID_TYPE(id) \
(((id) >> LV_PROPERTY_TYPE_SHIFT) & 0x0F)
#define LV_PROPERTY_ID_TYPE2(id) \
(((id) >> LV_PROPERTY_TYPE2_SHIFT) & 0x0F)For the property index, paired properties should extract only the lower 24 bits:
#define LV_PROPERTY_ID_INDEX2(id) \
((id) & 0x00FFFFFF)Single-value properties retain their documented 28-bit index.
I think the existing LV_PROPERTY_ID_INDEX usage should be reviewed to ensure that paired IDs are decoded correctly without changing the semantics of single-value IDs.
How to reproduce?
Create instances of a slider, animimage and roller, then retrieve their property IDs:
lv_obj_t *slider = lv_slider_create(lv_screen_active());
lv_obj_t *animimage = lv_animimg_create(lv_screen_active());
lv_obj_t *roller = lv_roller_create(lv_screen_active());
lv_prop_id_t ids[] = {
lv_obj_property_get_id(slider, "value"),
lv_obj_property_get_id(slider, "left_value"),
lv_obj_property_get_id(slider, "range"),
lv_obj_property_get_id(animimage, "src"),
lv_obj_property_get_id(roller, "options"),
lv_obj_property_get_id(roller, "selected")
};
for (size_t i = 0; i < sizeof(ids) / sizeof(ids[0]); i++) {
lv_prop_id_t id = ids[i];
printf("ID: 0x%08X\n", (unsigned int)id);
printf("TYPE: %u\n", (unsigned int)LV_PROPERTY_ID_TYPE(id));
printf("TYPE2: %u\n", (unsigned int)LV_PROPERTY_ID_TYPE2(id));
printf("INDEX: 0x%07X\n", (unsigned int)LV_PROPERTY_ID_INDEX(id));
printf("INDEX24: 0x%06X\n", (unsigned int)(id & 0x00FFFFFF));
}Output:
ID: 0x1B000800
TYPE: 1
TYPE2: 1
INDEX: 0xB000800
INDEX24: 0x000800
ID: 0x1B000801
TYPE: 1
TYPE2: 1
INDEX: 0xB000801
INDEX24: 0x000801
ID: 0x11000802
TYPE: 1
TYPE2: 1
INDEX: 0x1000802
INDEX24: 0x000802
ID: 0x51000900
TYPE: 5
TYPE2: 5
INDEX: 0x1000900
INDEX24: 0x000900
ID: 0x71000600
TYPE: 7
TYPE2: 7
INDEX: 0x1000600
INDEX24: 0x000600
ID: 0x11000601
TYPE: 1
TYPE2: 1
INDEX: 0x1000601
INDEX24: 0x000601
Compare the results against the documented LV_PROPERTY_ID2 bit layout. TYPE2 reports the value of TYPE1...
The discrepancy is reproducible with the existing LVGL property definitions and does not require custom property registration.
Activity
[-]LV_PROPERTY_ID_TYPE2 extracts the wrong bits and LV_PROPERTY_ID_INDEX includes TYPE2 for paired properties[/-][+][lv_prop_id_t]: Correct LV_PROPERTY_ID_TYPE2 and LV_PROPERTY_ID_INDEX macro for paired properties[/+]Wooohaaa commentedon Nov 11, 2026
A fix is up in #10984.
LV_PROPERTY_ID_TYPE2()now decodes bits27:24as documented, instead of reusingLV_PROPERTY_TYPE_SHIFT(it was literally identical toLV_PROPERTY_ID_TYPE()). It drives the setter dispatch inlv_obj_property.c, so this also fixes whicharg2type is passed to a two-argument setter (for exampleROLLER_OPTIONSwas going through the pointer variant andSLIDER_VALUEthrough the integer one). A regression test asserts the decodedTYPE/TYPE2; it fails before the change and passes after.On
LV_PROPERTY_ID_INDEX(): masking it down to 24 bits would truncate the 28-bit index of a single-valuedLV_PROPERTY_ID, and the two layouts cannot be told apart from the value alone, so it keeps the low 28 bits ofLV_PROPERTY_ID. For a pairedLV_PROPERTY_ID2the index is its low 24 bits (mask with0xffffffonceLV_PROPERTY_ID_TYPE2()says the id is paired); that is now documented next to the macro.fix(obj_property): decode the second argument type of a paired id
fvanroie commentedon Nov 11, 2026
Thank you for your prompt response, testing and fix!
One small follow-up thought: would it make sense to introduce an
LV_PROPERTY_ID_INDEX2()macro for paired properties?LV_PROPERTY_ID_INDEX()extracts 28 bits, whereas paired IDs use bits27:24for TYPE2, leaving only 24 bits for the index.Having separate macros would make the distinction explicit and avoid callers accidentally treating TYPE2 as part of the index.
Not necessarily something that needs to be addressed in this fix, just a thought for API consistency.
I'm coming from LVGL v7, so I'm still getting my head around the Widget Properties API.