immich icon indicating copy to clipboard operation
immich copied to clipboard

feat(mobile): add thumbhash support to gallery

Open lukehmcc opened this issue 2 years ago • 19 comments

Adds thumbhash support to gallery.

Doesn't look perfect but is a big improvement for poor network conditions.

https://github.com/immich-app/immich/assets/58121030/6ead3115-5cec-49cf-8744-b85d27d91d0a

lukehmcc avatar Jun 22 '23 14:06 lukehmcc

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
immich ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 5, 2023 0:11am

vercel[bot] avatar Jun 22 '23 14:06 vercel[bot]

Nicely done!

The Isar DLL and lock file should not be included in the repo.

Also we'd need to add a migration in migration.dart : simply clear and increase version. Otherwise assets that already had thumb hash on the server won't show them on the app.

Should be good now.

lukehmcc avatar Jun 23 '23 13:06 lukehmcc

Should be good now.

There is one outstanding comment that needs to be dealt with. Once this is done, PR looks good from my side.

fyfrey avatar Jun 23 '23 16:06 fyfrey

Should be good now.

There is one outstanding comment that needs to be dealt with. Once this is done, PR looks good from my side.

I staged my changes improperly :/ Sorry bout that.

Is that what you meant by the DB migration?

lukehmcc avatar Jun 23 '23 19:06 lukehmcc

@alextran1502 can you check this works fine on iOS? I could only test Android as you know :-)

fyfrey avatar Jun 27 '23 15:06 fyfrey

Hello @lukehmcc, thank you for the PR. Sorry, I am a bit late in reviewing and checking this PR out.

One issue I see is that the thumbnail is flashing in transition, which makes the browsing experience unpleasant. Look like it tries to transition between multiple states.

Can we figure out a way to fix the issue to have the transition smoother?

alextran1502 avatar Jun 28 '23 01:06 alextran1502

Hello @lukehmcc, thank you for the PR. Sorry, I am a bit late in reviewing and checking this PR out.

One issue I see is that the thumbnail is flashing in transition, which makes the browsing experience unpleasant. Look like it tries to transition between multiple states.

Can we figure out a way to fix the issue to have the transition smoother?

Yeah fs.

lukehmcc avatar Jun 28 '23 09:06 lukehmcc

I think we should use a placeholder instead of the progressIndicatorBuilder (that is rebuilt often)

fyfrey avatar Jun 28 '23 10:06 fyfrey

Found the culprit: the draggable scrollbar. When released, it triggers a rebuild of the asset grid (in turn rebuilding the placeholders / resetting the transition effect). This is not caused by the PR, it simply never surfaced before. The scrollbar already uses a RepaintBoundary, so not sure how to fix this.

edit: made #3010 to fix this issue. It also greatly improves performance!

fyfrey avatar Jun 28 '23 15:06 fyfrey

Found the culprit: the draggable scrollbar. When released, it triggers a rebuild of the asset grid (in turn rebuilding the placeholders / resetting the transition effect). This is not caused by the PR, it simply never surfaced before. The scrollbar already uses a RepaintBoundary, so not sure how to fix this.

edit: made #3010 to fix this issue. It also greatly improves performance!

Hmm even after applying this change to my branch I'm still getting flickering issues. I was previously testing via an emulator but I'm now using a physical device which makes these artfacts far more apparent. Will look into this more.

lukehmcc avatar Jun 29 '23 02:06 lukehmcc

It looks like using the FadeInImage class fixes the flicker but has its own issues so I'll keep looking. (It transitions from the placeholder, two black, to the main image which looks weird.)

lukehmcc avatar Jun 29 '23 14:06 lukehmcc

It looks like using the FadeInImage class fixes the flicker but has its own issues so I'll keep looking. (It transitions from the placeholder, two black, to the main image which looks weird.)

Ah good looks like blurhashes also have this issue. Will try to use the proposed solutions from there.

Update: It looks like flicker is a recurring issue with flutter cached network image. I don't think it has to do with any immich code at this point.

lukehmcc avatar Jun 29 '23 14:06 lukehmcc

@alextran1502 Just letting you know this PR should be good now.

lukehmcc avatar Jul 04 '23 15:07 lukehmcc

@lukehmcc Thank you for the reminder, I've just tested it again, and it looks a lot better. However, I still see some weird flashing issue when viewing different pages, like the album page or the page that show the assets of a person. Do you see the same issue?

alextran1502 avatar Jul 04 '23 15:07 alextran1502

@lukehmcc Thank you for the reminder, I've just tested it again, and it looks a lot better. However, I still see some weird flashing issue when viewing different pages, like the album page or the page that show the assets of a person. Do you see the same issue?

Hmm yes I do see that now. There must be a stray rebuild somewhere that I missed as this isn't the same flicker as before. Will dig a little.

lukehmcc avatar Jul 05 '23 23:07 lukehmcc

Can confirm that any given page (currently looking at the faces page) is built twice. Here is a debug log after clicking on a face:

I/ViewRootImpl@1918418[MainActivity]( 3289): ViewPostIme pointer 0
I/ViewRootImpl@1918418[MainActivity]( 3289): ViewPostIme pointer 1
...
I/flutter ( 3289): rebuildXhgKFIQmaop6Z2dPaKkYDmTDQA==
...
I/flutter ( 3289): rebuildXhgKFIQmaop6Z2dPaKkYDmTDQA==

Still not quite sure what exactly is causing this rebuild but at least I have down that the rebuild is happening only once.

lukehmcc avatar Jul 06 '23 00:07 lukehmcc

Still not quite sure what exactly is causing this rebuild but at least I have down that the rebuild is happening only once.

Made #3129 to reduce rebuilds of the asset grid. maybe this solves the issue?

fyfrey avatar Jul 06 '23 12:07 fyfrey

Still not quite sure what exactly is causing this rebuild but at least I have down that the rebuild is happening only once.

Made #3129 to reduce rebuilds of the asset grid. maybe this solves the issue?

Exactly we what needed! It now looks wonderful. Once that is merged this should be good :crossed_fingers:

lukehmcc avatar Jul 07 '23 01:07 lukehmcc

made a new PR to resolve the needless rebuilds causing flickering: #3226

fyfrey avatar Jul 12 '23 19:07 fyfrey

Just merged with main on my local branch and the flickering is now significantly worse. The thumbnail seems to rebuild half a dozen times before the image loads. Shoulda gotten this merged earlier when it wasn't an issue :/

EDIT: I didn't change any code, I just hot restarted a couple times and this flickering is now gone... Pls lmk if the flickering is still an issue.

lukehmcc avatar Aug 04 '23 23:08 lukehmcc

@lukehmcc the flicker issue was like that before any changes was made that was why we haven't merged the pr in yet.

I don't believe we changed anything that would make it worse

alextran1502 avatar Aug 04 '23 23:08 alextran1502

@lukehmcc the flicker issue was like that before any changes was made that was why we haven't merged the pr in yet.

I don't believe we changed anything that would make it worse

Yeah really not sure what was wrong there. Everything seems to be good on my end once more.

lukehmcc avatar Aug 05 '23 00:08 lukehmcc

@alextran1502 @lukehmcc has this PR been forgotten, or is there something blocking it?

bo0tzz avatar Sep 28 '23 17:09 bo0tzz

@alextran1502 @lukehmcc has this PR been forgotten, or is there something blocking it?

image Alex found flickering in some views that I couldn't reproduce. Last time I tested it was fine so I'm not sure.

lukehmcc avatar Sep 28 '23 18:09 lukehmcc

@lukehmcc / @alextran1502 I took a stab at the flickering issue in #4605. Can you check if you face the issue when scrolling the timeline? I was not sure whether it was okay to directly push my changes to your PR, so opened a new one for testing. If all is good, we can cherry pick the change and close my PR 😅

shenlong-tanwen avatar Oct 23 '23 08:10 shenlong-tanwen

Superceed by #4605

alextran1502 avatar Nov 20 '23 03:11 alextran1502