Skip to content

Keep decoded transcript images in Coil's memory cache - #144

Merged
Tarquinen merged 1 commit into
devfrom
coil-image-loading
Nov 18, 2026
Merged

Tarquinen merged 1 commit into
devfrom
coil-image-loading

Conversation

@Tarquinen

@Tarquinen Tarquinen commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

DecodedImageCache was a hand-rolled 48 MB LRU ported from iOS, running next to Coil's memory cache. A Markdown http image was held twice: once by Coil under its URL, and again by the app under its own key.

DecodedImageCache now keeps its image/insert API and SHA-256 keys but stores entries in Coil's shared memory cache. A Markdown http image loads through Coil under that same key, so it is held once. The LRU, budget and memory-pressure code is deleted. DecodedImageCacheTests, which only covered that code, is deleted too; the parity row says so.

These stay as they are: CachedImage.decoded (synchronous), the viewer's full-size decode, site icons, link-preview artwork and agent image previews. Each relies on things Coil doesn't do without extra code. A custom Coil Fetcher for server images would have added an abstraction and repeated the server's MarkdownImageCache.

Behaviour differences from dev

  • Transcript images use Coil's memory budget (a share of app memory) instead of a fixed 48 MB and 64 entries.
  • At TRIM_MEMORY_RUNNING_LOW Coil halves the cache instead of emptying it.
  • Nothing visible changes.

Verified

  • Full vm.sh check passes.
  • Emulator with session-lab, dev build against this branch:
    • Server-hosted Markdown images, "Tap to load", a failed image with retry, image links and the agent gallery look the same.
    • An http Markdown image (![](http://10.0.2.2:…/x.png), served from the VM host) behaves the same on both builds, with one GET in the server log for the whole run:
      • it appears;
      • scrolling it away and back shows no placeholder (checked frame by frame);
      • full screen and double-tap zoom work;
      • leaving the session and returning shows it in the first frame, with no new GET;
      • after a force-stop and relaunch it shows with no new GET (Coil's disk cache).
dev this branch
Server-hosted Markdown files, dev files, branch
Image links image links, dev image links, branch
Agent gallery gallery, dev gallery, branch
http Markdown image http image, dev http image, branch
http image zoomed zoom, dev zoom, branch

The dev http shot was taken with fresh app data, so its composer has no draft attachment.

Not tested

  • An https image from the public internet (the http path is the same code).
  • Behaviour under real memory pressure.

DecodedImageCache was a hand-rolled 48 MB LRU ported from iOS, kept next to
Coil's memory cache. A Markdown http image was held in both: Coil cached it
under its URL and the app cached the same bitmap again under its own key.

DecodedImageCache now stores its entries in Coil's shared memory cache
(SingletonImageLoader's), keeping its SHA-256 keys and its image/insert API,
and a Markdown http image loads through Coil under that same key, so it is
held once. The budget, LRU and memory-pressure trim are now Coil's.
DecodedImageCacheTests only covered the removed LRU and purge, so it is
deleted; the parity row says so.

Verified: vm.sh check (full) passes; emulator checks in the PR.
@Tarquinen
Tarquinen merged commit 198d661 into dev Nov 18, 2026
3 checks passed
@Tarquinen Tarquinen mentioned this pull request Nov 18, 2026

This branch was previously deployed

1 inactive deployment
release — 8e4d7b9f Deployed Nov 18, 2026 by Tarquinen via check #476
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.

1 participant