fix(lua): stream scripts off the SD card instead of buffering them whole
Reading a module into one String needs that many bytes contiguous. Once WiFi is up the largest free block drops to ~40KB, so loading /lib/ui.lua failed -- and readString() reports allocation failure by silently returning a partial read, which reached Lua as a syntax error at a random offset. Every app launch was broken while connected. loadScript() now feeds lua_load() through a 512 byte buffer, so no module needs a contiguous allocation. readScript(), still used by fs.readFile, verifies the length it got against the file size rather than trusting it. The launch log carries free and largest-block so the next heap question is answerable without a rebuild.
This commit is contained in:
+1
-1
@@ -50,7 +50,7 @@ void startApp(const String& path) {
|
||||
// Full panel until the app's own status bar module reports its height in load().
|
||||
tft.setRotation(settings.rotationIndex()); // apps may have rotated the frame
|
||||
tft.resetViewport(); // load() re-clips once the new app's bar reports its height
|
||||
Serial.printf("launching %s\n", path.c_str());
|
||||
Serial.printf("launching %s free=%u largest=%u\n", path.c_str(), ESP.getFreeHeap(), ESP.getMaxAllocHeap());
|
||||
if (app.load(path.c_str(), path == HOME)) return;
|
||||
if (path == HOME) fallbackScreen("home failed to start");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user