Skip to content

dart:ui Pictures can retain SkImage objects, causing increased GPU memory usage #28912

@ds84182

Description

@ds84182

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.

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: performanceRelates to speed or footprint issues (see "perf:" labels)customer: money (g3)engineflutter/engine related. See also e: labels.perf: memoryPerformance issues related to memory

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions