Merge develop into main (#348)

## App state

Improved app state management in `LoaderService` and `GuiService`:

- Re-ordered some of the state transitions
- Hardened `GuiService` for repeated events (that might trigger a re-render of an app that's already rendered)
- Validate state transitions in `LoaderService` and crash if an app transitions from the wrong state to the next one.

## LoaderService

- Removed `tt::loader::` functions and expose `LoaderService` interface publicly.
- Implement `stopAll()` and `stopAll(id)` which stops all instances of an app, including any apps that were launched by it.
- Rename `stop()` functions to `stopTop()`
- Created `stopTop(id)` which only stops the top-most app when the app id matches.
- Moved `loader::LoaderEvent` to `loader::LoaderService::Event`
- Changed app instance `std::stack` to `std::vector`

## Improvements

- `ElfApp`: error 22 now shows a hint that `main()` might be missing
- Starting, installing and uninstalling apps now stops any running app (and its children) on the stack

## Bugfixes

- `HttpdReq` out of memory issue now shows an error message and doesn't crash anymore (this would happen on devices without PSRAM with WiFi active, when an app was installed)
- `GuiService::hideApp()` lock should not wait for timeout and now waits indefinitely
- `Buildscript/release-sdk-current.sh` deletes the previous local release before building a new one

## Code correctness

- App classes were made `final`
- Apps that had a `void start()` now have a `LaunchId start()`
- `tt::app::State`: renamed `Started` to `Created` and `Stopped` to `Destroyed` to properly reflect earlier name changes
This commit is contained in:
Ken Van Hoeylandt
2025-09-27 18:04:09 +02:00
committed by GitHub
parent dcf28d0868
commit f6cdabf3c0
48 changed files with 504 additions and 342 deletions
@@ -15,8 +15,10 @@
namespace tt::app::crashdiagnostics {
extern const AppManifest manifest;
void onContinuePressed(TT_UNUSED lv_event_t* event) {
service::loader::stopApp();
stop(manifest.appId);
launcher::start();
}
@@ -48,7 +50,7 @@ public:
int qr_version;
if (!getQrVersionForBinaryDataLength(url_length, qr_version)) {
TT_LOG_E(TAG, "QR is too large");
service::loader::stopApp();
stop(manifest.appId);
return;
}
@@ -56,7 +58,7 @@ public:
auto qrcodeData = std::make_shared<uint8_t[]>(qrcode_getBufferSize(qr_version));
if (qrcodeData == nullptr) {
TT_LOG_E(TAG, "Failed to allocate QR buffer");
service::loader::stopApp();
stop();
return;
}
@@ -64,7 +66,7 @@ public:
TT_LOG_I(TAG, "QR init text");
if (qrcode_initText(&qrcode, qrcodeData.get(), qr_version, ECC_LOW, url.c_str()) != 0) {
TT_LOG_E(TAG, "QR init text failed");
service::loader::stopApp();
stop(manifest.appId);
return;
}
@@ -84,7 +86,7 @@ public:
pixel_size = 1;
} else {
TT_LOG_E(TAG, "QR code won't fit screen");
service::loader::stopApp();
stop(manifest.appId);
return;
}
@@ -99,7 +101,7 @@ public:
auto* draw_buf = lv_draw_buf_create(pixel_size * qrcode.size, pixel_size * qrcode.size, LV_COLOR_FORMAT_RGB565, LV_STRIDE_AUTO);
if (draw_buf == nullptr) {
TT_LOG_E(TAG, "Draw buffer alloc");
service::loader::stopApp();
stop(manifest.appId);
return;
}
@@ -130,7 +132,7 @@ extern const AppManifest manifest = {
};
void start() {
service::loader::startApp(manifest.appId);
app::start(manifest.appId);
}
} // namespace