Open hb020 opened 2 days ago
This is typical behavior for memory exhaustion. Your ESP32 running on fumes and its behavior becomes erratic or crashes...
Large pages.jsonl, with many large images and many (large) fonts.
large and many are rather vague... Can you quantify how many and how big?
So large, that without LV_MEM_CUSTOM, it would crash at every page change with an "out of memory" message.
It seems you've hit some limits in LVGL with the number of objects and data that fits in the reserved LVGL memory (LV_MEM_SIZE ) and decided to extend the LVGL memory by sharing it with OS memory. LV_MEM_CUSTOM pools both LVGL and OS memory together, this allows more flexibility but can/will increase memory fragmentation.
You'll need to keep a close eye on memory consumption and see where/why the memory is consumed. Instead of enabling LV_MEM_CUSTOM , it should be better to (slightly) increase LV_MEM_SIZE to where it fits your objects.
Can you quantify how many and how big?
pages.jsonl: 448 lines, 52kB, fonts sizes used: 16, 24, 32, 40, 50, 66, 175 files: 235 files, 5.2MB, apart from some small cmd files and the pages.jsonl, all .bin files
I already tried making a bin file of the 175 size font, no change seen.
Instead of enabling LV_MEM_CUSTOM , it should be better to (slightly) increase LV_MEM_SIZE to where it fits your objects.
Can I go over 64k?
Situation now:
Device Memory
--
Free Heap | 20.47 KiB
Free Block | 8.73 KiB
Fragmentation | 57%
PSRam Free | 1.82 MiB
PSRam Size | 1.99 MiB
Module
--
Model | ESP32-S3 rev0
Frequency | 240MHz
Core Version | 4.4.6
Reset Reason | CPU0: POWERON_RESET / CPU1: POWERON_RESET
Flash Size | 16.00 MiB
Program Size Used | 1.60 MiB
Program Size Free | 1.93 MiB
Filesystem Size | 11.93 MiB
Filesystem Used | 5.06 MiB
Filesystem Free | 6.87 MiB
Yes, you can go over 64kB if you have a lot of pages/objects/parameters set. That will prevent LVGL out of memory errors. You'll take a fixed amount of free Heap and convert that into available LVGL memory. The amount depends... don't go too high if LVGL doesn't really need it. This will prevent LVGL from hogging system memory and reduce fragmentation.
Check the logs to see the available system memory: eg [13044/27244 52]
means 13kB continuous free block of 27kB free Heap and 52% fragmentation. Disabling LV_MEM_CUSTOM will add a second memory meter for LVGL memory too.
Try adding 8kB LVGL memory, if it's too big reduce by 4kB, if too small add 4kB, etc... But try to keep 25~30kB of system memory free.
Will try the memory settings. (72kB seems to work so far)
Still, if the serving of the 52kB pages.jsonl file poses problems, is it served in one block or is it streamed out? Because uploading the file to the device poses no problem, the downloading does.
yes, it streams in blocks of 1360 bytes it seems.
Issue be closed, but I was initially under the impression that LV_MEM_CUSTOM would make use of full PSRam, which is not the case at all. This, plus the explanation of what the memory info in the console logs mean, might benefit from explicit documentation somewhere.
That documentation maybe exists somewhere, but I haven't found it. I am even willing to write it, provided you tell me where.
These are inner workings of LVGL and described in include\lv_conf_v7.h
, not even in the LVGL docs...
LV_MEM_CUSTOM uses these allocators:
#define LV_MEM_CUSTOM_ALLOC malloc /*Wrapper to malloc*/
#define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/
If you want to use PSram instead, change the define to ps_malloc
if the device actually has PSram.
Or use hasp_malloc
which will check if PSram is available first and use it if it does.
I haven't used LVGL memory in PSram, so please test and report if it works fine.
The openHASP documentation repo is here: https://github.com/HASwitchPlate/openHASP-docs or click the Edit icon at the top of each page to edit it.
Perform all steps below and tick them with [x]
Describe the bug
#define LV_MEM_CUSTOM 1
with large HTTP network requests makes the device hang for about 10 minutes.To Reproduce
SC01 Plus on 0.7.0-rc14 (wt32-sc01-plus_ota_v0.7.0-rc14_80a9ddb.bin, wt32-sc01-plus_16MB) in user_config_override.h (amongst others):
Large pages.jsonl, with many large images and many (large) fonts. So large, that without LV_MEM_CUSTOM, it would crash at every page change with an "out of memory" message.
With LV_MEM_CUSTOM it allows page changes and appears stable, EXCEPT:
when starting the http server and requesting edit of
/pages.jsonl
MQTT: Disconnected
andMQTT: Transport error
in loops"template": "%H:%M:%S"
) stops advancingMQTT: Not connected ??? page => 4
WIFI: key update timeout
/pages.jsonl
will start everything over againSee console log (real IP address and SSID are obfuscated, 0.0.0.0 was left as it):
The only way to get to that
pages.jsonl
, is to reset the device and not touch it before requesting the page via browser.Once the
pages.jsonl
is loaded, updating/saving it is no problem, no matter the screen interactions.Note that the
WIFI: key update timeout
can take much longer than 10 minutes, I was just "lucky" in this published sample.Expected behavior
no hanging
Screenshots or video
tell me what you want me to do to get more detailed logs