Skip to content

fix: prevented OOM crash when fetching or rendering large articles#1154

Merged
spacecowboy merged 7 commits into
masterfrom
crashing-feed
Jun 5, 2026
Merged

fix: prevented OOM crash when fetching or rendering large articles#1154
spacecowboy merged 7 commits into
masterfrom
crashing-feed

Conversation

@spacecowboy

@spacecowboy spacecowboy commented May 31, 2026

Copy link
Copy Markdown
Owner

Added two caps to prevent the app running out of memory when "Parse
full article" fetches a page whose content is too large to process:

  • Abort with a FullTextTooLarge error if the raw HTTP response body
    exceeds 1 MB
  • Cap the number of LinearElements produced by HtmlLinearizer at 2000, or total text count of 100 000;
    further nodes are dropped and a truncation notice is appended so the
    user still sees a partial article
  • Show a dedicated error message with an "Open in browser" button when
    a full article is too large to parse

fixes #1103

Truncated example

Screenshot_20260605_102417

Added two caps to prevent the app running out of memory when "Parse
full article" fetches a page whose content is too large to process:

- Abort with a FullTextTooLarge error if the raw HTTP response body
  exceeds N MB, or if the HTML extracted by Readability4J exceeds
  200 KB of characters
- Cap the number of LinearElements produced by HtmlLinearizer at 3000;
  further nodes are dropped and a truncation notice is appended so the
  user still sees a partial article
- Show a dedicated error message with an "Open in browser" button when
  a full article is too large to parse

Signed-off-by: Jonas Kalderstam <[email protected]>
Signed-off-by: Jonas Kalderstam <[email protected]>

Copilot AI 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.

Pull request overview

Adds three protective caps to the "Parse full article" flow to avoid OOM crashes on very large pages (e.g. grapheneos.org/releases.atom): a size cap on the fetched HTTP body, a size cap on the extracted Readability output, and a hard cap on the number of LinearElements produced by HtmlLinearizer. A new FullTextTooLarge FeedParserError is plumbed through to the article UI, which shows a dedicated message plus an "Open in Web view" button.

Changes:

  • Add FullTextTooLarge error and enforce MAX_FULL_TEXT_BYTES (1 MB) and MAX_ARTICLE_CONTENT_CHARS (200 KB) in FullTextParser.
  • Cap HtmlLinearizer output at MAX_ELEMENTS = 3000 via a new addLimited(...) helper and append a truncation notice when reached.
  • Map the new error to TextToDisplay.FAILED_FULLTEXT_TOO_LARGE and render it in ArticleScreen with an open-in-browser button; add it to the search-feed exhaustive when.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
app/src/main/java/com/nononsenseapps/feeder/model/FullTextParser.kt Adds pre/post size caps on response body and extracted article.
app/src/main/java/com/nononsenseapps/feeder/model/FeedParser.kt New FullTextTooLarge FeedParserError data class.
app/src/main/java/com/nononsenseapps/feeder/model/html/HtmlLinearizer.kt Adds MAX_ELEMENTS cap, addLimited, truncation notice, and renames LOG_TAG.
app/src/main/java/com/nononsenseapps/feeder/archmodel/Repository.kt Adds FAILED_FULLTEXT_TOO_LARGE enum value.
app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/ArticleViewModel.kt Maps FullTextTooLarge to the new TextToDisplay value.
app/src/main/java/com/nononsenseapps/feeder/ui/compose/feedarticle/ArticleScreen.kt Plumbs onOpenInCustomTab into ArticleContent and renders the new error state.
app/src/main/java/com/nononsenseapps/feeder/ui/compose/searchfeed/SearchFeedScreen.kt Handles new error in exhaustive when.
app/src/main/res/values/strings.xml New failed_to_fetch_full_article_too_large string.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/main/java/com/nononsenseapps/feeder/model/FullTextParser.kt
Comment thread app/src/main/java/com/nononsenseapps/feeder/model/FeedParser.kt
Signed-off-by: Jonas Kalderstam <[email protected]>
Signed-off-by: Jonas Kalderstam <[email protected]>
Signed-off-by: Jonas Kalderstam <[email protected]>

Copilot AI 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.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.

Comment thread app/src/main/java/com/nononsenseapps/feeder/model/FullTextParser.kt
Comment thread app/src/main/java/com/nononsenseapps/feeder/model/FullTextParser.kt Outdated
Comment thread app/src/main/java/com/nononsenseapps/feeder/ui/compose/text/HtmlToComposable.kt Outdated
Signed-off-by: Jonas Kalderstam <[email protected]>
Signed-off-by: Jonas Kalderstam <[email protected]>

Copilot AI 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.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Comment thread app/src/main/java/com/nononsenseapps/feeder/model/FullTextParser.kt
@spacecowboy spacecowboy changed the title fix: prevented OOM crash when fetching full article for large pages fix: prevented OOM crash when fetching or rendering large articles Jun 5, 2026
@spacecowboy spacecowboy enabled auto-merge (squash) June 5, 2026 09:07
@spacecowboy spacecowboy merged commit 99fb3d8 into master Jun 5, 2026
13 checks passed
@spacecowboy spacecowboy deleted the crashing-feed branch June 5, 2026 09:10
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.

App crashes opening feed article

2 participants