fix: prevent Manage Fonts OOM crash with many SD fonts installed#347
Conversation
Opening Settings > Fonts > Manage Fonts aborted during manifest parsing on devices with many SD-card font families installed. At the parse peak the full font registry, the parsed manifest JsonDocument, and the families_ list were all resident at once, exhausting the heap; with exceptions disabled the failing allocation calls abort(). - onEnter() now releases the whole font registry via releaseForNetwork() (not just the active glyph font), matching the KOReader sync/auth pre-network release. - fetchAndParseManifest() parses in two passes: build families_ from the JSON, free the JsonDocument, then load the registry to resolve installed/update state, so the JSON and registry never coexist. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 23aba785cc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| if (family.files.empty()) { | ||
| continue; | ||
| families_.push_back(std::move(family)); |
There was a problem hiding this comment.
Avoid exposing unresolved families after parse errors
When a later manifest entry fails validation after at least one family has been pushed here, fetchAndParseManifest() returns before the second pass fills installName. The ERROR screen still offers Retry/Back for non-empty families_, and downloadFamily() uses family.installName for ensureFamilyDir()/buildFontPath(), so a staged row can be downloaded with an empty install name and write files under /.fonts//... instead of a family directory. Stage parsed families in a local vector until the whole manifest validates, or clear/resolve them before any error return.
Useful? React with 👍 / 👎.
Opening Settings > Fonts > Manage Fonts aborted during manifest parsing on devices with many SD-card font families installed. At the parse peak the full font registry, the parsed manifest JsonDocument, and the families_ list were all resident at once, exhausting the heap; with exceptions disabled the failing allocation calls abort().