-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
gpui: Prepaint Div children with image cache #46039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
Veykril
approved these changes
Jan 5, 2026
Member
Veykril
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
rtfeldman
pushed a commit
that referenced
this pull request
Jan 5, 2026
Closes #39914 I was able to reproduce the issue on macOS using the same README. The root cause was that `markdown_preview_view` attaches the image cache to the root div, and while Div correctly applies that cache during request_layout and paint, the prepaint phase didn’t have the same context. Markdown is rendered through a List, and `List::prepaint` renders its items using `layout_as_root`. That meant images were getting loaded during prepaint without the image cache in place. When that happened, Img fell back to the global asset loader, which retains assets indefinitely unless explicitly cleaned up. So every image was loaded twice: - once during layout/paint via RetainAllImageCache (correctly released when the preview closed) - once during prepaint via the global asset system (never released) The result was doubled memory usage and a leak, since the globally loaded images stuck around after the preview was closed. Release Notes: - Fixed a memory leak when previewing markdown files with images Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
LivioGama
pushed a commit
to LivioGama/zed
that referenced
this pull request
Jan 20, 2026
Closes zed-industries#39914 I was able to reproduce the issue on macOS using the same README. The root cause was that `markdown_preview_view` attaches the image cache to the root div, and while Div correctly applies that cache during request_layout and paint, the prepaint phase didn’t have the same context. Markdown is rendered through a List, and `List::prepaint` renders its items using `layout_as_root`. That meant images were getting loaded during prepaint without the image cache in place. When that happened, Img fell back to the global asset loader, which retains assets indefinitely unless explicitly cleaned up. So every image was loaded twice: - once during layout/paint via RetainAllImageCache (correctly released when the preview closed) - once during prepaint via the global asset system (never released) The result was doubled memory usage and a leak, since the globally loaded images stuck around after the preview was closed. Release Notes: - Fixed a memory leak when previewing markdown files with images Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
LivioGama
pushed a commit
to LivioGama/zed
that referenced
this pull request
Jan 20, 2026
Closes zed-industries#39914 I was able to reproduce the issue on macOS using the same README. The root cause was that `markdown_preview_view` attaches the image cache to the root div, and while Div correctly applies that cache during request_layout and paint, the prepaint phase didn’t have the same context. Markdown is rendered through a List, and `List::prepaint` renders its items using `layout_as_root`. That meant images were getting loaded during prepaint without the image cache in place. When that happened, Img fell back to the global asset loader, which retains assets indefinitely unless explicitly cleaned up. So every image was loaded twice: - once during layout/paint via RetainAllImageCache (correctly released when the preview closed) - once during prepaint via the global asset system (never released) The result was doubled memory usage and a leak, since the globally loaded images stuck around after the preview was closed. Release Notes: - Fixed a memory leak when previewing markdown files with images Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
cla-signed
The user has signed the Contributor License Agreement
community champion
Issues filed by our amazing community champions! 🫶
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #39914
I was able to reproduce the issue on macOS using the same README.
The root cause was that
markdown_preview_viewattaches the image cache to the root div, and while Div correctly applies that cache during request_layout and paint, the prepaint phase didn’t have the same context.Markdown is rendered through a List, and
List::prepaintrenders its items usinglayout_as_root. That meant images were getting loaded during prepaint without the image cache in place. When that happened, Img fell back to the global asset loader, which retains assets indefinitely unless explicitly cleaned up.So every image was loaded twice:
The result was doubled memory usage and a leak, since the globally loaded images stuck around after the preview was closed.
Release Notes: