Repository navigation
The desktop app keeps at most 32 MB of a chat's pictures in memory, decoding them as their rows are drawn - #194
Conversation
… keeps at most 32 MB of them Every picture of the open chat was decoded when its details loaded and kept until another chat opened: about 160 MB for 100 photos, plus their GPU copies. Now a picture is decoded when its row is drawn (on screen or within the list's overdraw), and past 32 MB, the Mac app's budget, the least recently drawn are let go, GPU copies included; a row drawn again decodes it again.
…t a time skipping rows scrolled past, and the tests cover scrolling back, dropped copies and real drawing
Review (
|
What changed
Files::look, called only for rows the timeline builds (on screen plus the list's 400 px overdraw), records each drawn picture and queues the ones with nothing decoded. The row callback then starts a single worker that decodes them one at a time, the most recently drawn first, skipping rows already scrolled past.PICTURE_BUDGET, the Mac app'sThumbnailsbudget, about 20 photos). Past it, the least recently drawn are let go throughcx.drop_image, which frees their GPU copies as well. A row drawn again decodes its picture again.Why
The desktop app kept every decoded picture of the open chat until another chat opened: up to 1.6 MB each, about 160 MB for 100 photos, plus the GPU copies once scrolled through.
Measured
scrolling_through_many_photos_keeps_their_pictures_within_a_budgetscrolls a row at a time through 150 photos, each decoded at full size (640×640, 1.6 MB), with four on screen.Testing
cargo test -p hush-desktop: 108 passed. clippy-D warningsandcargo fmt --checkare clean.load_media→client.file_bytes) is checked by reading only. The snapshot demo inserts its pictures directly, so it doesn't go through that path.Closes #185