8000 fix(reader): load a folded card's message only when it opens by gonzisdev · Pull Request #581 · hyprlab/hylki · GitHub
[go: up one dir, main page]

Skip to content

fix(reader): load a folded card's message only when it opens - #581

Closed
gonzisdev wants to merge 1 commit into
hyprlab:mainfrom
gonzisdev:fix/reader-lazy-folded-frames
Closed

gonzisdev wants to merge 1 commit into
hyprlab:mainfrom
gonzisdev:fix/reader-lazy-folded-frames

Conversation

@gonzisdev
@gonzisdev gonzisdev commented Nov 4, 2026 •
Copy link
Copy Markdown
Contributor

Problem

Opening a long conversation makes memory grow without bound until the app is killed. With a Gmail thread of 83 messages (each reply quoting the full history, about 50 MB of bodies), Hylki 1.46.1 (Flatpak, Fedora 45) went past 12 to 18 GB within seconds of selecting it; journalctl shows the scope ending at a 14.3G memory peak and the log is full of WebKit's "Blocked script execution in 'about:srcdoc'" lines, one batch per card.

Cause

A folded card (#326) hides its frame with .hylki-folded>:not(.hylki-fbar):not(.hylki-msg-hdr){display:none}, but a display:none iframe still loads and lays out its srcdoc. So a thread folded down to its newest card still renders every message.

Change

  • card_body: when the card is folded at render time, the frame's document goes in data-hylki-srcdoc instead of srcdoc.
  • Wrapper script: a wake(f) moves it back to srcdoc (resetting the frame's init flags so init runs on the real document) when the card opens, from foldCard and from patch_folds.
  • A test checks that a folded card's frame defers its document and an open one does not; the golden files are updated for the script change and for the folded card in three_cards.html.

Printing is unaffected, as it builds its own document.

I have not built or run this locally, so please treat it as a proposal and check it with cargo test and a long thread.

A folded card hid its frame with CSS, but a hidden frame still loads and renders its whole document, so a conversation folded down to its newest card rendered every message at once. A Gmail thread of 83 quoted replies took the app past 14 GB within seconds of opening and it was killed. A folded card's frame now keeps its document in a data attribute and gets it when the card is opened, by hand or by a fold change.
@gonzisdev
gonzisdev force-pushed the fix/reader-lazy-folded-frames branch from dc4e041 to a0d4a23 Compare November 4, 2026 15:31
hyprlab added a commit that referenced this pull request Nov 5, 2026
A hidden frame still loads its document, so a long conversation held every message in memory at once. Folded frames also count as settled for the page's ready signal and the send animation, and an opened frame takes the current zoom.

Co-Authored-By: Gonzalo Vasco López <167196987+gonzisdev@users.noreply.github.com>
hyprlab added a commit that referenced this pull request Nov 5, 2026
First beta after 1.47.0: MCP access for AI agents (#577) and folded cards that load when opened (#581).
@hyprlab
hyprlab commented Nov 5, 2026
Copy link
Copy Markdown
Owner

Agentic reply:

This is in 1.48.0-beta.1, with your change as written plus three additions: a folded card counts as ready at once when a conversation opens, the send animation does not wait for it, and a card takes the current zoom when it opens. Find in Message now looks only through the cards that are open.

I tested this on a short conversation, not one as long as yours, so:

  1. Open your 83-message conversation in the beta.
  2. Say here whether memory stays down.

The beta build is in the repo now. If you already have the beta installed, flatpak update picks it up. If not, download and install it first:

flatpak install --user --from https://hylki.hyprlab.co/flatpak/co.hyprlab.Hylki.Beta.flatpakref

RPM, Debian and AppImage betas: Beta channel.

@hyprlab hyprlab closed this Nov 5, 2026
@gonzisdev
Copy link
Copy Markdown
Contributor Author

Thanks for merging it so quickly. I tested 1.48.0-beta.1 (Flatpak) with the 83-message conversation; the memory still blows up, but the picture is different now:

  • With Fold messages = Never (my setting at first) nothing is folded, so the change does not apply: every frame loads and memory reached 15 GB until the web view went down and restarted.
  • With Collapse earlier messages (all_but_newest), the frames do stay empty (only a few dozen about:srcdoc lines instead of hundreds), but the hylki process itself grows: 17.6 GB RSS two minutes after opening the conversation, while WebKitNetworkProcess stays at about 100 MB and the web processes are small. So the remaining cost seems to be on the Rust side while the conversation is assembled or rendered, not in WebKit.

The thread is a Gmail one (IMAP, XOAUTH2): Fwd: … with 83 messages in the conversation (294 across folders) and about 50 MB of bodies in the cache, most of it quoted history. Happy to run a build with more logging or to collect anything else that helps.

@gonzisdev
Copy link
Copy Markdown
Contributor Author

A likely lead for the hylki process growth: the conversation is attachment-heavy. In the cache, 251 of its 303 messages have attachments, 385 attachment rows totalling about 210 MB (largest 12.7 MB; images and PDFs), against only about 21 MB of bodies. Opening the conversation seems to prepare the card attachments and thumbnails for every message (load_thread_attachments / push_card_attachments), and decoding that many images and first PDF pages at full size would fit the 17 GB RSS in the main process. Limiting thumbnails to open cards, or decoding them at thumbnail size, might be worth checking.

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

0