You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Skia] A bitmap cache entry evicted by the LRU leaves its shared decoded surface to finalization #25128
With the bitmap cache enabled, a decoded BitmapImage surface that went through _bitmapImageCache is owned by the cache: the LRUCache entry holds the Task<ImageData>, and every BitmapImage that loaded the same key shares the result. When the LRU evicts that entry (capacity reached in Add, or Trim removing an idle entry on a memory-pressure interval), nothing owns the surface anymore. The sources still displaying it keep it alive through their ImageData, which is fine, but once they all unload nothing releases the decoded pixels deterministically: a cache-shared surface is never released by a source (one source cannot know whether another still displays it), so it goes to the finalizer chain, which is the path #25114 / #25124 removes for uncached surfaces.
The same applies to an in-flight cached load whose requesters all cancelled before it completed and whose entry was evicted meanwhile: the result is produced, marked shared, and dropped only by finalization.
Expected behavior
Cache entries that know their users, as WinUI's ImageCache does (it is released by its last BitmapImage, ImageProvider::RemoveImageCache / ImageCache::~ImageCache): a reference-counted entry whose surface is released when the entry has left the cache and its last requester has unsubscribed, and an evicted in-flight load with no remaining requesters releasing its eventual result.
Context
Follow-up to #25114 (deterministic release of uncached surfaces, PR #25124), raised during the review of #25124. The pre-existing behaviour for cached surfaces is unchanged by that PR.
Activity
fix(imaging): Release cached decodes, keep encoded bytes instead (port)
fix(imaging): Release a shared decode nothing displays
fix(imaging): Release a shared decode nothing displays