Skip to content

Keep album thumbnail cells across message binds - #2278

Draft
mpretty-cyro wants to merge 1 commit into
session-foundation:devfrom
mpretty-cyro:fix/album-thumbnail-reuse
Draft

mpretty-cyro wants to merge 1 commit into
session-foundation:devfrom
mpretty-cyro:fix/album-thumbnail-reuse

Conversation

@mpretty-cyro

@mpretty-cyro mpretty-cyro commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Contributor checklist

  • I have tested my contribution on these devices:
  • Virtual device: Pixel 6 profile, API 37 (arm64), 2 cores / 2 GB, play flavour, qa
  • My contribution is fully baked and ready to be merged as is
  • I ensure that all the open issues my contribution fixes are mentioned in the commit message of my first commit using the Fixes #1234 syntax

Description

Slow frames when scrolling past image messages. VisibleMessageContentView.bind started every bind by calling albumThumbnailView.clearViews(). That removed the album's cells and reset the size AlbumThumbnailView reuses them for, so its reuse check never matched. Every image message inflated its cell layout again on every bind, and the new ThumbnailViews started Glide loads even when the slide hadn't changed.

The album is already hidden at the start of each bind and only shown again for image messages, so the cells are now left in place:

  • AlbumThumbnailView reuses them whenever the album needs the same layout. Albums of three or more images all share the three-cell layout, and the "and N more" text is now set on every bind.
  • A ThumbnailView that's already showing the same slide skips the load. Its existing equality check covers uri, thumbnailUri and transferState, so a changed or newly downloaded slide still reloads.

The clearViews() call on the attachment-download path is unchanged.

Confidence: high that it removes the re-inflation. Medium on how much it helps real scrolling, which depends on how often neighbouring albums share a layout. Most image messages are single images.

Testing: a local build of 1.33.9 with this change and the record cache (#2277) on top, on a Note to Self with albums of 1, 2, 3 and 4 images mixed among texts. With a temporary counter (not in this PR), one scripted scroll did 29 image-message binds: 15 reused their cells and 14 inflated. Before this change every one of them inflates. The test data deliberately alternates album sizes; runs of single images reuse every time.

I checked by eye:

  • albums of 1–4 images, with the four-image album showing three cells and "+1";
  • an image message deleted on this device shows the deleted placeholder;
  • image messages sent afterwards, while scrolling back and forth.

Every bind of a message started by clearing the album view, which removed its cells and reset what it reuses them for. So every image message inflated its cells again on each bind, and its thumbnails started new Glide loads even when the slide hadn't changed. The album is already hidden at the start of each bind and shown only for image messages, so the cells are now left in place. They're reused whenever the album needs the same layout, which albums of three or more share (the "and N more" text is now set on every bind), and a cell showing the same slide skips the load.

@mpretty-cyro mpretty-cyro left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

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