-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Internal: b/140831274
Branching off of #19558. Dart's GC has no information about objects retained by Pictures. This causes the GC to ignore collecting Picture objects while it collects Images instead. However, the internal SkImage is shared with the Picture's underlying SkPicture, so collecting just the Images and ignoring the Pictures causes GPU memory usage to skyrocket when lots of high resolution images are displayed. This even happens when manually disposing Images directly after usage.
Testing my app, after a lot of scrolling there were 2,088 Picture objects currently allocated, and only 87 were strongly reachable. These Picture objects internally have a reference to internal SkImages, and the GC has no knowledge of that. Doing a manual GC in the Observatory, then loading another image (this is required by Skia to recover GPU memory) resulted in GPU usage going down to 512mb (the configured max limit).
I have no clue how to communicate to Dart's GC that a Picture references Images and Paths and etc. other than collecting all resources into a List in Picture's methods.