Lodepng_error: memory allocation failed - ESP32

Hi!

It seems on ESP32 port the lodepng library is still not using the custom (MicroPython) memory allocation function from mp_lodepng.c file, instead it uses the old malloc(), and that throws a memory allocation error.

Although the LODEPNG_NO_COMPILE_ALLOCATORS is defined in lv_bindings/mkrules.cmake file, the compiled lodepng.cpp file is still using malloc().
Could you please check it on your M5Core2 device (or other device)?

Thank you!

Repro steps:

  1. Add following line to lv_bindings/driver/png/lodepng/lodepng.cpp file line #78 (inside lodepng_malloc() function):
    printf("* LODEPNG-OLD-malloc *");

  2. Add following line to lv_bindings/driver/png/mp_lodepng.c file line line #11 (inside lodepng_malloc() function):
    printf("* LODEPNG-NEW-malloc *");

  3. Download attached test app (see below: png-test.zip) to your Linux dev environment

  4. Edit, then run run-linux-simulator.sh script
    Result: LODEPNG-NEW-malloc text is shown in console, and PNG image is shown in TFT Simulator window

  5. Edit, then run run-m5core2.sh script
    Result: LODEPNG-OLD-malloc text is shown, no image on device, and there is also an error message: lodepng_error: memory allocation failed

png-test.zip (11.7 KB)

Thanks for reporting this @PGNet !

It’s a bug - the LODEPNG flags were set only for preprocessing and not for compilation.

Fixed now for ESP32 on latest lv_micropython.

Hi @amirgon,
Thanks, it works now!

PS:
When I find an another bug, should I create an issue in Github (for PR fix), or report in this LVGL forum?

It’s better to open GitHub issues for bugs.