Constraints on SD card access: no free file descriptors #173
Replies: 4 comments
-
In the meantime, incrementing file descriptors in SD.begin() mitigates the error but still, why so many files opened at the same time? What are the underlying processes that make this happen and is there any way of reducing its use? |
Beta Was this translation helpful? Give feedback.
-
Moving that to a support discussion since this is not related to ESPAsyncWebServer but more about how FS works on ESP32. There are some issues in browsing the FS: slow and takes resources. You can also see this discussion: mathieucarbou/ESPAsyncWebServer#165 (reply in thread) I would suggest to refactor your app, use the lest possible disk access (eventually refactor your UI to only serve 1 big file and/or use WebSocket like ESP-DASH). Flash access is slow and should be avoided as much as possible, and concurrent access even more. |
Beta Was this translation helpful? Give feedback.
-
what do you see in the network tab of the browser debug console? How many javascripts are requested? In your handler up there you print directory list, which consumes some open file descriptors. Can you provide a full minimal compilable example and maybe screenshot of the bowser network requests when a fail occurs? |
Beta Was this translation helpful? Give feedback.
-
I have done some debugging, and at the error point i have opened:
This makes 5 file descriptors which is the max default. All should work flawlessly. So, i believe Audio-tools or AWS could possibly have one more opened file/directory somewhere. This makes sense with my findings above: if i bring the file to a String and then close the file, the callback works as expected (less one file descriptor being used). Now that this makes sense, we can close this topic. I am sorry for the confusion and thank you @mathieucarbou @me-no-dev ! Have a great day and keep the good work 🙏 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Platform
ESP32
IDE / Tooling
PlatformIO
What happened?
Hi, I am using Arduino-audio-tools with this library but in different RTOS tasks.
I made a custom class networkManager which simplifies the user experience in the main setup/loop functions for this library. I made a callback function _jsProcessorCallback so whenever the user needs to process a javascript file variables, he can just attach his own templateProcessor.
The error pops when an audio file is already being played (not in the same directory) and the AWS has a request for its index: simple html, css and js files (Using minified versions from 450 lines of code in total).
In the user template processor callback, the variable "%audio_files%" triggers a process of accessing SD and retrieving a list of files in a directory. (~25 files in total).
I cannot find a clear answer but i believe this has something to do with AWS internal queuing. If i use AWS method for accessing SD directly, it probably takes too long to close the files so i run out of file descriptors and so i cannot get the list.
User callback:
The buggy way (works if audio player is not being used):
But if i get the file, store the content into a String and send it, the error disappears (always works):
Stack Trace
Minimal Reproductible Example (MRE)
Cannot get an MRE at the moment
I confirm that:
Beta Was this translation helpful? Give feedback.
All reactions