fix: pre-flight heap floor before section builds; no inline BLE restart
Layout code (line-break DP arrays, CSS lookups, glyph buffers) allocates via std::vector/std::string and abort()s on OOM under -fno-exceptions -- it cannot fail cleanly mid-build. Field crashes (X4, BLE resident): builds entered at ~11 KB free and aborted in ParsedText:: computeLineBreaks; an inline BLE restart after recovery re-starved the render and abort()ed in FontCacheManager's scanText_.reserve at ~8 KB. - BUILD_MIN_FREE_HEAP (40 KB): pre-flight before the build; below the floor go straight to recovery instead of attempting a doomed build - Recovery no longer restarts NimBLE inline; the lifecycle stays paused until the render completes (scoped unpause guard), then the main-loop lifecycle restarts BLE behind its own heap gate
This commit is contained in:
@@ -56,6 +56,14 @@ class EpubReaderActivity final : public Activity {
|
||||
SavedPosition savedPositions[MAX_FOOTNOTE_DEPTH] = {};
|
||||
int footnoteDepth = 0;
|
||||
|
||||
// Heap floor for entering a section build. The layout code allocates freely (line-break DP
|
||||
// arrays sized by word count, CSS rule lookups, glyph buffers) and under -fno-exceptions an
|
||||
// OOM there abort()s the firmware instead of failing cleanly -- so a starved heap must be
|
||||
// handled *before* the build, not after. Field data: builds succeed at ~46 KB free with BLE
|
||||
// resident; abort() observed at ~11 KB free. CSS styling already degrades below 48 KB
|
||||
// (MIN_FREE_HEAP_FOR_CSS), so 40 KB trades a few early BLE teardowns for not crashing.
|
||||
static constexpr size_t BUILD_MIN_FREE_HEAP = 40 * 1024;
|
||||
|
||||
void renderContents(std::unique_ptr<Page> page, int orientedMarginTop, int orientedMarginRight,
|
||||
int orientedMarginBottom, int orientedMarginLeft);
|
||||
void renderStatusBar() const;
|
||||
|
||||
Reference in New Issue
Block a user