Trying to use new SVG support, failing to render anything

Description

LVGL (very) recently gained an internal SVG decoder. I am trying to use it and failing.

What MCU/Processor/Board and compiler are you using?

LVGL+SDL on Debian 12, LVGL+linuxfb on an old embedded device.

What LVGL version are you using?

master @ c30e18df3c648c4f9f2a24d6ae4a8ddab300d8db (a few commits after the merge of add VG rendering support

What do you want to achieve?

Render an SVG onto a canvas.

What have you tried so far?

Based on the code in test_draw_svg.c I have tried to render an SVG onto a canvas.

Setting LV_CACHE_DEF_SIZE to 128kb, and setting LV_BIN_DECODER_RAM_LOAD to 1 did not help.

Code to reproduce

The forum template asked for

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

I don’t have that yet (but I will try to split it out like that soon). (I just noticed that the lv_port_linux simulator has a one-week-too-old LVGL for this).

The failing code is in icon stuff by Habbie · Pull Request #129 · voorkant/voorkant-core · GitHub, as of commit e094ef872f55b401993e641c47901a596029552a titled enable LVGL logging.

Screenshot and/or video

Code to reproduce in the lv_port_linux simulator (after bumping the lvgl subproject and adding #define LV_USE_SVG 1 to lv_conf.h):

    lv_layer_t layer;
    lv_obj_t *canvas = lv_canvas_create(lv_scr_act());
    lv_draw_buf_t *canvas_buf = lv_draw_buf_create(480, 480, LV_COLOR_FORMAT_ARGB8888, 0);
    lv_canvas_set_draw_buf(canvas, canvas_buf);
    lv_canvas_fill_bg(canvas, lv_color_make(0xff, 0xff, 0xff), 255);
    lv_canvas_init_layer(canvas, &layer);

    const char* svg_group_1 = "<svg><g fill=\"#FF0000\">"
                            "<rect x=\"0\" y=\"0\" width=\"100\" height=\"100\"/>"
                            "<circle cx=\"100\" cy=\"100\" r=\"50\"/>"
                            "<ellipse fill=\"#00F\" cx=\"200\" cy=\"200\" rx=\"100\" ry=50/>"
                            "</g></svg>";
    
    lv_svg_node_t* svg = lv_svg_load_data(svg_group_1, lv_strlen(svg_group_1));
    lv_image_cache_drop(canvas_buf);
    lv_canvas_set_draw_buf(canvas, canvas_buf);
    lv_canvas_fill_bg(canvas, lv_color_make(0xff, 0xff, 0xff), 255);
    lv_draw_svg(&layer, svg);
    lv_canvas_finish_layer(canvas, &layer);
    lv_svg_node_delete(svg);

Great news: this does actually work! Now I get to figure out why it does not work in the context of my project.

Setting LV_USE_THORVG_INTERNAL to 0 on the simulator version breaks the rendering (looks identical to the screenshot above then). No interesting logging from it. In my own project, setting LV_USE_THORVG_INTERNAL to 1 breaks the build with a linking error which I need to investigate.

I had understood that this new SVG lib did not rely on ThorVG at all. I may have misunderstood, but silent failure feels like a bug maybe?

Needed -llvgl_thorvg.