arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
21.71k stars 4.72k forks source link

Ufs serve fix - makes it work better on esp32cam (ai thinker style) #21486

Closed btsimonh closed 1 month ago

btsimonh commented 1 month ago

Description:

Related issue (if applicable): fixes #21473

This changes the rarely used UFSServe code enabled by #ifdef UFILESYS_STATIC_SERVING to be like the file download code.

For me, this makes the file serving much more reliable on slower devices like the ESP Chip Id 3667140 (ESP32-D0WDQ6 v1.0)

Prior to this change, I would see a random main loop hang on accessing files.

I have tested with >5000 file downloads on ESP32S3 and >1500 downloads on esp32cam (ai thinker style), and had better results. I don't think this is a complete fix, as I have had one device lose connection (unfortunately without serial) - but this could have been something else.

This PR also adds yield() in file list from the GUI. This is tested and does not cause a watchdog on a 1500 file folder. (the main thread is hung during this time - many seconds). I'm not sure if there can be a better solution whilst the webserver can handle a single client. One would be a re-write of the JS to poll for more files - but this may not help as even finding files in a large folder takes a lot of time. Having this many files in a folder on an IOT device seems unusual, so it may be better to document and live with it.

Checklist:

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

btsimonh commented 1 month ago

@Jason2866 - pls comment on the use of yield in file listing.

Jason2866 commented 1 month ago

yield does give the core time "doing needed" things and resets the WDT. So probably a good idea :-) What I do not like very much is the left debug code. Either you think it is needed so keep it active (maybe change to more debug) or remove it completely.

s-hadinger commented 1 month ago

Looks good to me. Ok to merge

btsimonh commented 1 month ago

@Jason2866 - point taken. none of it is active, as it's all hashed out.