Skip to content

feat(web): don't animate cached thumbnails #20773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

uhthomas
Copy link
Collaborator

@uhthomas uhthomas commented Aug 7, 2025

Description

Thumbnails for assets always are displayed with a thumbhash which fades out over 100ms, even if the thumbnail is cached and ready immediately. This can be a bit distracting and make Immich feel 'slow', or inefficient as it feels like the thumbnails are always being reloaded. Skipping the thumbhash and animation for cached thumbnails makes it feel much more responsive.

How Has This Been Tested?

Locally.

I can attach a couple of videos to compare, but also we can see how it feels side-by-side in the preview env.

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR.
  • I have confirmed that any new dependencies are strictly necessary.
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code
  • All code in src/services/ uses repositories implementations for database calls, filesystem operations, etc.
  • All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services/)

Copy link
Contributor

github-actions bot commented Aug 7, 2025

Deploying preview environment to https://pr-20773.preview.internal.immich.cloud/

@uhthomas uhthomas requested a review from alextran1502 August 7, 2025 21:10
@uhthomas uhthomas force-pushed the feat-no-thumbhash-cache branch from a44bce8 to dd4a4cb Compare August 7, 2025 21:13
@uhthomas uhthomas force-pushed the feat-no-thumbhash-cache branch 3 times, most recently from 846f192 to 88b3ff6 Compare August 7, 2025 22:13
@uhthomas uhthomas force-pushed the feat-no-thumbhash-cache branch from 88b3ff6 to 747a480 Compare August 7, 2025 22:16
></canvas>
{#if asset.thumbhash}
{#await isCached(new Request(thumbnailURL))}
<canvas
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a second canvas which doesn't fade out, it's used whilst it's waiting to check if the thumbnail is already in the cache. If the thumbnail is cached, then it is removed immediately, whereas if the thumbnail is not cached then the other canvas is used and that will fade out when the actual thumbnail is ready to use.

@uhthomas uhthomas added preview and removed preview labels Aug 7, 2025
@uhthomas uhthomas force-pushed the feat-no-thumbhash-cache branch from 747a480 to 04abdec Compare August 7, 2025 22:31
@midzelis
Copy link
Collaborator

midzelis commented Aug 9, 2025

Note - Window.caches is only available in secure contexts.

style:height="{height}px"
class:rounded-xl={selected}
draggable="false"
out:fade={{ duration: THUMBHASH_FADE_DURATION }}
Copy link
Member

@mertalev mertalev Aug 9, 2025

Choose a reason for hiding this comment

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

I'm not sure how the two canvases behave - is it decoding the thumbhash and allocating a canvas twice, or does it know they're the same thing? It might be better to use the same canvas and just change the fade value here with reactive state. So the state starts with null/undefined and switches to this value once we know it's a cache miss.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was thinking the same thing, I'll do that.

@uhthomas uhthomas force-pushed the feat-no-thumbhash-cache branch from 04abdec to 26f8995 Compare August 10, 2025 19:49
Thumbnails for assets always are displayed with a thumbhash which fades out
over 100ms, even if the thumbnail is cached and ready immediately. This can be
a bit distracting and make Immich feel 'slow', or inefficient as it feels like
the thumbnails are always being reloaded. Skipping the thumbhash and animation
for cached thumbnails makes it feel much more responsive.
@uhthomas uhthomas force-pushed the feat-no-thumbhash-cache branch from 26f8995 to 2bba33f Compare August 10, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants