Very slow image viewing experience even all image thumbnail generated by preview generator
Faster Image viewing experience after pre-generate all thumbnail.
Android version:
8.0.0
Device model:
Sony Xperia XZ2
Stock or customized system:
No
Nextcloud app version:
3.2.1
Nextcloud server version:
13.0.5
No error
Insert your webserver log here
[26/Jul/2018:10:07:57 +0800] "GET /nextcloud/index.php/apps/files/api/v1/thumbnail/256/256/Photo/2015/06/IMG_20150620_103208.jpg HTTP/1.1" 200 18874 "-" "Mozilla/5.0 (Android) ownCloud-android/3.2.1" "-"
No new message
Insert your Nextcloud log here
No new message
NOTE: Be super sure to remove sensitive data like passwords, note that everybody can look here! You can use the Issue Template application to prefill some of the required information: https://apps.nextcloud.com/apps/issuetemplate
As I try to solve the problem, I think the issue is that android app didn't pull all thumbnail simultaneously. It pull the thumbnail one by one, which make it much slower compare webpage version.
I noticed this as well, the mobile app is very slow when displaying image thumbnails in tile view, even though the thumbnails have been pregenerated and display immediately in web view. It doesn't feel like the mobile app is using the pregenerated thumbnails, because how can it take 15 seconds to display a single tiny thumbnail?? It feels like it's generating each thumbnail, not using the pre-generated ones.
I'd expect the app to use the pre-generated thumbnails but can't say for sure. Maybe @rullzer and @tobiasKaminsky know more about it.
It might in some cases come to some waiting time due to other asynchronous server calls and I know that @tobiasKaminsky is working on a rewrite of the thumbnail fetching/caching on the Android client which might improve the situation.
Is there maybe a way to improve things with HTTP/2 and push content? I.e the server can preemptively push thumbnails when a directory is opened in the app. This might need tweaking in case of thousands of files, but should otherwise be very fast.
No fix yet on displaying photos quicker on the android app?
The endpoint in use does use the pregenerated previews. Of course it all still has to be fetched
The endpoint in use does use the pregenerated previews. Of course it all still has to be fetched
That's really good. However the speed isn't so good. About 20 seconds to load a folder with 28 thumbnails for 28 jpegs over fast WiFi on a local server. Using Opera browser with the same folder takes about 8-10 seconds, including scrolling to see all pictures.
@rullzer out of interest which component is the bottleneck here, redis? Surely it should be a matter of milliseconds for the server to return a preview that has already been generated?
Edit: Just looking at my RP3 nextcloud server, browsing via the web interface it takes about 11 seconds to return a photo preview from the following endpoint:
/index.php/core/preview.png?file=***.jpg&c=c202022857e9109d1a5a2dd390375cf8&x=32&y=32&forceIcon=0
This endpoint is different to the one above and I don't know if it uses the same underlying pipeline, but 1 second to return a preview image is too much let alone 11! What's the fundamental issue here that needs addressing to fix these response times?
@nero120 are you 100% certain the previews for that file are all properly generated already? Because on my production sytem retruning a preview is <300ms
@rullzer I believe so, if I browse to the list view of a folder (with browser cache disabled) most of the previews do appear pretty much immediately, however there seems to be always one that takes ages to appear. If I then browse directly to the link of the slow preview image (as above) it takes ~11 seconds to appear:

I don't want to take this off topic but I wondered if this was related at all to the title issue.
@nero120 no that is not the fault of android. Please open an issue in the server repo. And maybe attach the image that is causing trouble.
The android client just fetches this from the server there is no magic involved there.
Ok thanks @rullzer.
So this can be closed as Roeland pointed out that this is a server issue.
If you find out that this is related to Android, please re-open.
I guess the issue is really the extreme slowness in loading previews. Perhaps the topic is just badly worded. It feels like pre-generated previews aren't used because it is so slow, while in fact it is the way how the android client fetches them.
I gave Nextcloud a try and left after just a couple of days because of the Android App in specific. Don't worry, it's not just you. I also used that recommended thumbnail preview generation app which helped with Desktop/Web but didn't do jack for the Android client.
Douglas Parker
From: Gatak notifications@github.com
Sent: Wednesday, November 7, 2018 1:13:48 AM
To: nextcloud/android
Cc: Douglas Parker; Manual
Subject: Re: [nextcloud/android] Nextcloud app didn't use thumbnail generated by preview generator (#2850)
I guess the issue is really the extreme slowness in loading previews. Perhaps the topic is just badly worded. It feels like pre-generated previews aren't used because it is so slow, while in fact it is the way how the android client fetches them.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHubhttps://github.com/nextcloud/android/issues/2850#issuecomment-436556085, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARZBriXtM8Jyyit3X6TL95a5OfYYvlLTks5usqRMgaJpZM4VhEH0.
Sorry for anyone who receives a notification now but: @nero120 did you open an issue on the server side and did anything happen? Could not find anything in the server repository issues. The speed in the android app is insanely slow while the web app is fast
@mathiasmoeller ack no I didn't, must have slipped my mind completely 😦
@nero120 no that is not the fault of android. Please open an issue in the server repo. And maybe attach the image that is causing trouble.
The android client just fetches this from the server there is no magic involved there.
@rullzer Might it be that the android client fetches every preview image one by one in a single connection? Even if the previews are generated and small this might cause the long waiting time.
Might it be that the android client fetches every preview image one by one in a single connection? Even if the previews are generated and small this might cause the long waiting time.
It is likely. I do think previews are used, but the sequential way they are downloaded is very slow. about 0.5-1 second per picture.
So technically, the bug report is probably incorrect in that the app is using the pre-generated previews (can someone verify?). However the meaning of the report is that the images load really slowly, so in that context I think this bug report should be re-opened. I don't think it is a server issue.
So technically, the bug report is probably incorrect in that the app is using the pre-generated previews (can someone verify?).
I don't know the android app codebase well, I can see that it has a class ThumbnailsCacheManager that does request the correct endpoint, but whether that line is triggered correctly by the thumnbnail view, and whether it is using a single thread to request all thumbnails I'm not entirely sure.
@tobiasKaminsky likely to knows best while I think they are loaded sequentially and also there is a older PR that not quite fully working to switch to glide for fetching and caching images from the server.
Yes, pictures are handled one by one, but still it should not take 1s per photo as each thumbnail is ~30kb at most.
Yup. But it does, even when I have very fast WiFi connection on the same LAN as the server.
Poking at the server code (for the first time!), I can see that it's not using any advanced mechanism for using the _existing_ thumbnail that already exists in the file, there's no check for using the thumbnail that's already present in the metadata of the image.
I'm willing to bet that any image made by a device in the last 5 years probably has this data.
https://stackoverflow.com/questions/10349622/extract-thumbnail-from-jpeg-file
private function generatePreview(ISimpleFolder $previewFolder, ISimpleFile $maxPreview, $width, $height, $crop, $maxWidth, $maxHeight, $prefix) {
$preview = $this->helper->getImage($maxPreview);
....
$preview->preciseResize((int)round($scaleW), (int)round($scaleH));
....
$preview->resize(max($width, $height));
}
@dgtlmoon please move discussion to server repo, as this has to be fixed / discussed there.