Comments (13)
I'd like to propose two enhancements to improve the UX:
(1) Use low-res to start with
- Use the already cached low resolution version of the album view to start with
- Once the actual image for the lightbox is loaded, change to this version
No problem with that.
(2) Pre-load of images
- Preload the neighboring (i.e. predecessor and successor) images of the album when a new image is display in the lightbox
This is actually already implemented (but only one picture each side: previous and next).
from lychee-front.
(1) Use low-res to start with
- Use the already cached low resolution version of the album view to start with
- Once the actual image for the lightbox is loaded, change to this version
No problem with that.
I agree it's a good suggestion. Do you have an idea how to implement it though? Things get complicated with @2x
images: we don't actually know which one is in the cache (for small
) or which one the browser is planning to load (for medium
). Is there a way to query the browser cache content from JS? A quick web search didn't return any obvious answers...
(2) Pre-load of images
This is actually already implemented (but only one picture each side: previous and next).
Actually, I believe we only do it for the next (photo.preloadNext
). We could of course expand it to cover both previous and next but I'm not sure if that would make the matters better or worse (i.e., parallel loading of two images will only make things slower, although in the case of somebody browsing from one image to the next, the previous one is likely to be cached already).
from lychee-front.
(1) Use low-res to start with
- Use the already cached low resolution version of the album view to start with
- Once the actual image for the lightbox is loaded, change to this version
No problem with that.I agree it's a good suggestion. Do you have an idea how to implement it though? Things get complicated with
@2x
images: we don't actually know which one is in the cache (forsmall
) or which one the browser is planning to load (formedium
). Is there a way to query the browser cache content from JS? A quick web search didn't return any obvious answers...
You're right, the implementation seems to be much more complicated than I thought in the first place. What about the following idea (don't know it if works in the end):
You can access the current source of an image using currentSrc (https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement). We look at the thumbnail in the album view and have 3 cases:
- currentSrc = small: -> use the small version
- currentSrc = @2x -> use the @2x version
- currentSrc = placeholder -> (for discussion) use the small version
What do you think?
(2) Pre-load of images
This is actually already implemented (but only one picture each side: previous and next).Actually, I believe we only do it for the next (
photo.preloadNext
). We could of course expand it to cover both previous and next but I'm not sure if that would make the matters better or worse (i.e., parallel loading of two images will only make things slower, although in the case of somebody browsing from one image to the next, the previous one is likely to be cached already).
- Does not work consistently
Did some more testing - it does not seem to work consistently.
Safari (on Mac): Next image is not preloaded. Looking at the traffic, it seems like Safari is loading the thumb version of the next image, but not the medium one. Without looking at the traffic, it seems the iPhone behaves on the same way.
Firefox: Is working - Loading previous image
This should only make the first image view slower. When iterating forwards, the previous image is already cached. When iterating backwards, preloading of previous image is helpful (next image is already cached)
from lychee-front.
What about the following idea (don't know it if works in the end):
You can access the current source of an image using currentSrc (https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement).
Yes, we actually use currentSrc
already, in the preload code. I was thinking about it and came up with pretty much the same idea as you have.
We look at the thumbnail in the album view and have 3 cases:
- currentSrc = small: -> use the small version
- currentSrc = @2x -> use the @2x version
- currentSrc = placeholder -> (for discussion) use the small version
What do you think?
Yeah, exactly. When switching from the album view to the photo view (by clicking on a thumbnail) the thumbnails aren't actually removed from the screen; they just get covered up. So it should be quite simple to look up the thumbnail and initially display whatever it is displaying (since that's obviously cached). Regarding the 3rd scenario above, I would simply do nothing (i.e., fall back to what we currently do) as that's not a common case.
- Does not work consistently
Did some more testing - it does not seem to work consistently.
Safari (on Mac): Next image is not preloaded. Looking at the traffic, it seems like Safari is loading the thumb version of the next image, but not the medium one. Without looking at the traffic, it seems the iPhone behaves on the same way.
Firefox: Is working
The thumb loading you're seeing is due to the background images behind the "prev" and "next" arrows of the currently displayed photo.
We are using standard HTML5 link prefetching. Indeed, according to https://caniuse.com/#feat=link-rel-prefetch you are correct that Safari doesn't support it. Shame. Given that pretty much every other browser supports it, I'm not exactly motivated to do anything about it. But if somebody submitted a clean PR we would probably consider it (preloading can be achieved in JS without HTML5 by creating an Image object and setting its source to the desired URL)...
- Loading previous image
This should only make the first image view slower. When iterating forwards, the previous image is already cached. When iterating backwards, preloading of previous image is helpful (next image is already cached)
Yes, exactly.
from lychee-front.
Given that pretty much every other browser supports it, I'm not exactly motivated to do anything about it.
👍
from lychee-front.
This discussion reminded me of something that bothered me about Lychee from the beginning: the fact that the last picture wraps around to first when you click on the next arrow. I never liked that so I now fixed it (well, I made it configurable) and in the process I also started working on your list. 😃
@tmp-hallenser, can you test the branch nextprev-improvements
of Lychee-front and see if prefetching now works on Safari?
from lychee-front.
@tmp-hallenser I completed the implementation of this request in #130. It would be great if you could test it and provide feedback, especially with respect to the prefetching on Safari, which is currently untested.
from lychee-front.
Gave it a brief test - Safari now preloads the medium size image -> that's good. Many thanks!
I did some further testing regarding page speed and realized, that calling photo:get is now not the most time consuming call. In my case, the network protocol shows roughly 1000ms waiting before the transfer starts. (this is of course not related to the network speed but rather to the large library combined with low power of server). Hence another idea to improve the speed:
Can we also preload the call of photo:get?
There is the function preload which might be useful: https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content
Unfortunately, the feature is disabled for Firefox by default.
https://caniuse.com/#search=preload
from lychee-front.
I have what I think is a fairly low-end server (a cloud instance with 512 MB RAM) that's over 1000km from me and Photo::get takes under 200ms on average, which I find quite acceptable.
DevTools in Chrome include a snazzy "Server Timing" breakdown under Network (I had no idea such info is even sent...) -- can you see if there's anything interesting in there that would shed some light into why it's much slower for you?
from lychee-front.
Here, same, my server is 1000km away and I have more than 6000 pictures on it. I still get responses over Photo::get
within 100ms and my Laravel instance is runing inside a Virtualbox VM on my server.
from lychee-front.
My server (Docker on a raspberry) is in the same wifi and I've got approx. 30k photos.
The Server Timing is not shown for my installation and I found quite little resources on how to get it working. My timings for photo:get are:
Queueing: 1.34 ms
Stalled: 0.41 ms
Request sent: 0.22 ms
Waiting (TTFB): 1.19 s (<- that's the issue)
Content download: 1.52 ms
I've logged into the mysql server. A "SELECT * from photos WHERE ID=(some ID)" returns the result in 2ms -> that's also not the bottle neck.
I'll do some more testing if I find some more free time.
from lychee-front.
Did some further testing and the issue must be somewhere in my config. When using the provided Dockerfile based on Debian, I'm down to 180ms waiting compared to >1s (ngninx on an alpine base image)
from lychee-front.
I'm closing this issue since the originally requested functionality has been implemented.
from lychee-front.
Related Issues (20)
- suggestion: remove google fonts dependency HOT 2
- iOS Mobile Site - No scrolling of target list on move of picture HOT 1
- Mov files get imported with thumbnail but only sound is played HOT 2
- Css is too complex to permit anyone to create new theme HOT 6
- Wrong support of ' (single quote) in some places (French localisation)
- 'About' window stays open when viewing 'Settings' and other sections in sidebar HOT 1
- Problem with responsive design on iOS
- [Enhancement] Make login dialog more prominent, auto-show login dialog if necessary, hide empty smart folders for anonymous users HOT 12
- Refreshing (F5) an album or photo from within the search results fails with 422 HOT 4
- [Enhancement] SEO optimization 2/3 - Set `<meta name="robots" content="noindex">` for 404 responses
- [Enhancement] SEO optimization 3/3 - Don't use fragments for client-side navigation, but proper URLs HOT 6
- [Enhancement] SEO optimization 4/3 - Use `<a>`-tags in a semantical correct way
- Scroll position should only be restored when navigating from photos back to their album HOT 9
- [Regression] Photos in the unsorted album cannot be edited HOT 1
- On iPad Pro - the settings menu does not disappear HOT 6
- WebAuthn.js does not work on older Safari versions HOT 2
- Share button is shown on photo page even if `share_button_visible` is not set
- Album view: wrong line breaks when scrollbars are visible HOT 1
- Photo view: More menu shows when it shouldn't HOT 2
- Link for Logs is invalid HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lychee-front.