Skip to content

fix: prevent Manage Fonts OOM crash with many SD fonts installed#347

Merged
uxjulia merged 1 commit into
uxjulia:developmentfrom
pillarsdotnet:development
Jul 7, 2026
Merged

fix: prevent Manage Fonts OOM crash with many SD fonts installed#347
uxjulia merged 1 commit into
uxjulia:developmentfrom
pillarsdotnet:development

Conversation

@uxjulia

@uxjulia uxjulia commented Jul 7, 2026

Copy link
Copy Markdown
Owner

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.

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>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@uxjulia
uxjulia merged commit 23aba78 into uxjulia:development Jul 7, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants