feat: silent-restart defrag on section-build double failure + BLE debug flags

- EpubReaderActivity: when a section build fails even after the BLE
  teardown/retry, silentRestartToReader() as last-resort heap defrag,
  guarded by bootWasSilentRestart() to prevent reboot loops
- main/SilentRestart.h: expose bootWasSilentRestart()
- platformio.ini: enable FREEINK_BLE_HID_REPORT_DEBUG in env:default
This commit is contained in:
Nick
2026-07-02 17:20:51 -05:00
committed by Nick McCarthy
parent c463da994e
commit 06aa1ac2f7
4 changed files with 23 additions and 0 deletions
@@ -33,6 +33,7 @@
#include "QrDisplayActivity.h"
#include "ReaderUtils.h"
#include "RecentBooksStore.h"
#include "SilentRestart.h"
#include "components/UITheme.h"
#include "fontIds.h"
#include "util/BookmarkUtil.h"
@@ -883,6 +884,16 @@ void EpubReaderActivity::render(RenderLock&& lock) {
bleinput::showConnectingUntilLinked(renderer, mappedInput);
requestGhostCleanup();
}
if (!built && !bootWasSilentRestart()) {
// Even with BLE freed, the build can fail when this session's parse churn has
// fragmented the heap beyond in-place recovery. A silent restart is the only
// real defrag on this heap (no compaction); it resumes into this book and
// rebuilds the section on a fresh heap. Guarded by bootWasSilentRestart() so a
// build that fails again after the restart degrades to the error popup below
// instead of reboot-looping.
LOG_ERR("ERS", "Section build failed after BLE recovery; silent restart to defrag heap");
silentRestartToReader();
}
if (!built) {
LOG_ERR("ERS", "Failed to persist page data to SD");
section.reset();