Add framebuffer lending for memory-intensive builds

Temporarily release framebuffer memory during section pagination to reduce heap pressure. The framebuffer can be released before memory-intensive operations and restored afterward, allowing BLE stack startup threshold to be lowered from 80KB to 70KB. Implements RAII-style FrameBufferBuildLoan class to ensure proper cleanup and automatic restart on restoration failure.
This commit is contained in:
Justin Mitchell
2026-07-09 00:04:11 -04:00
parent f3da5e4f06
commit 05c1e9aa46
15 changed files with 205 additions and 147 deletions
@@ -156,15 +156,6 @@ class EpubReaderActivity final : public Activity {
void loop() override;
void render(RenderLock&& lock) override;
bool isReaderActivity() const override { return true; }
// Hold BLE off only while the background build has catch-up work pending inside
// its window (same condition loop() uses to tick it). Gating on isBuilding() alone
// would hold BLE off for the rest of the chapter — a windowed build stays
// "building" until the reader walks the whole spine. Unlocked read, same pattern
// as the background-build check in loop().
bool deferBluetoothStart() const override {
return section && section->isBuilding() &&
static_cast<int>(section->pageCount) < section->currentPage + BUILD_WINDOW_AHEAD;
}
void requestGhostCleanup() override { pagesUntilFullRefresh = 1; }
ScreenshotInfo getScreenshotInfo() const override;
CrossPointPosition getCurrentPosition() const;