android icon indicating copy to clipboard operation
android copied to clipboard

Fix Performance Issue While Scrolling in the Gallery

Open alperozturk96 opened this issue 1 year ago • 21 comments

Before: https://github.com/nextcloud/android/assets/67455295/f7f23b71-cb50-4860-bb12-fc251d8b0fab

After: https://github.com/nextcloud/android/assets/67455295/a0886ee7-3b63-48f9-b8b0-186f23b5b44a

  • [x] Tests written, or not not needed

alperozturk96 avatar Nov 03 '23 13:11 alperozturk96

/rebase

alperozturk96 avatar Nov 20 '23 19:11 alperozturk96

/rebase

alperozturk96 avatar Nov 21 '23 08:11 alperozturk96

During a brief test, I've noticed that video files (e.g. the default Nextcloud intro.mp4) in the media tab appear to flicker between the placeholder image and a blank background. The file still opens as expected when I click on the blank spot. Is this a known issue?

ZetaTom avatar Nov 21 '23 12:11 ZetaTom

@ZetaTom Yes same on master.

Video Thumbnail Flickering

https://github.com/nextcloud/android/assets/67455295/fe509b6b-93e8-4f62-b364-5bd0fe946a92

alperozturk96 avatar Nov 21 '23 13:11 alperozturk96

/rebase

alperozturk96 avatar Nov 22 '23 08:11 alperozturk96

/rebase

alperozturk96 avatar Nov 22 '23 10:11 alperozturk96

@alperozturk96, I've attached a recording of the flicker that I'm experiencing on my end.

https://github.com/nextcloud/android/assets/70907959/8f6bff9f-46b6-4cc9-ae0f-f6dac012a80e

ZetaTom avatar Nov 27 '23 11:11 ZetaTom

@ZetaTom I used correct placeholder and disable Glide animation could you try again? Can't able to see issue on my device.

alperozturk96 avatar Nov 27 '23 15:11 alperozturk96

/rebase

tobiasKaminsky avatar Dec 03 '23 08:12 tobiasKaminsky

/rebase

alperozturk96 avatar Dec 18 '23 08:12 alperozturk96

@tobiasKaminsky GalleryFragmentIT.showEmpty() this test fails. Somehow trying to set adapter with null argument. I put debugger but it didn't trigger during UI test.

GalleryFragment extends from OCFileListFragment and both have setAdapter() function. Do you have any idea to fix it?

alperozturk96 avatar Dec 18 '23 11:12 alperozturk96

/rebase

alperozturk96 avatar Dec 22 '23 09:12 alperozturk96

Before

master

After

pr

We have performance problem in Media tab. We solved with appyling some different method to display images and came across problem with FIT_XY scale type, it was causing the alignment problem. When we use CROP_CENTER scale type alignment problem solved and right now we are zooming a bit to the center of image in the list.

My question is what designers think about the new look, is it acceptable? I think CROP_CENTER scale type looks good.

@nextcloud/designers

alperozturk96 avatar Feb 07 '24 15:02 alperozturk96

We found weird problem, when user scroll so fast in the media list sometimes app redirects us to login page and sometimes behave like crash. When we investigate the log we didn't see any crash.

crash.logcat.zip

We are using Glide for fetching images and it have internal caching mechanism.

    private val baseUri = client.getClientFor(user.toOwnCloudAccount(), context).baseUri
    private val previewLink = "/index.php/core/preview.png?file="
    private val imageDownloadWidth = "&x=$defaultThumbnailSize"
    private val imageDownloadHeight = "&y=$defaultThumbnailSize"
    private val mode = "&a=1&mode=cover&forceIcon=0"
    private val defaultImageDimension = ImageDimension(defaultThumbnailSize, defaultThumbnailSize)
    
    private fun getImageUrl(file: OCFile): String {
        return baseUri.toString() +
            previewLink +
            URLEncoder.encode(file.remotePath, Charsets.UTF_8.name()) +
            imageDownloadWidth +
            imageDownloadHeight +
            mode
    }
    
   val (width, height) = size
   val imageUrl = getImageUrl(file)
   val placeholder = getPlaceholder(file, width, height)

  Glide
         .with(context)
         .using(CustomGlideStreamLoader(user, clientFactory))
         .load(imageUrl)
         .asBitmap()
         .diskCacheStrategy(DiskCacheStrategy.SOURCE)
         .placeholder(placeholder)
         .dontAnimate()
         .into(thumbnail)

These codes executing during scroll. If we sent too much request like that in short period of time can backend kicked us out?

@artonge @tobiasKaminsky

alperozturk96 avatar Feb 07 '24 15:02 alperozturk96

I guess that so many requests can lead the server to request the user to log in again. Either due to brute force protection, or token renewal. I would bet on the later. Can you share the request that fails and the data returned by the server?

artonge avatar Feb 07 '24 17:02 artonge

We have performance problem in Media tab. We solved with appyling some different method to display images and came across problem with FIT_XY scale type, it was causing the alignment problem. When we use CROP_CENTER scale type alignment problem solved and right now we are zooming a bit to the center of image in the list.

My question is what designers think about the new look, is it acceptable? I think CROP_CENTER scale type looks good.

@nextcloud/designers

Does that mean every picture now has the same size? I would argue this sounds like a regression since it was intended that each picture is shown completely afaik... Of course if technically not better possible I would say that performance is more important than this detail but WDYT @jancborchardt @nimishavijay @marcoambrosini ?

szaimen avatar Feb 09 '24 11:02 szaimen

We have performance problem in Media tab. We solved with appyling some different method to display images and came across problem with FIT_XY scale type, it was causing the alignment problem. When we use CROP_CENTER scale type alignment problem solved and right now we are zooming a bit to the center of image in the list. My question is what designers think about the new look, is it acceptable? I think CROP_CENTER scale type looks good. @nextcloud/designers

Does that mean every picture now has the same size? I would argue this sounds like a regression since it was intended that each picture is shown completely afaik... Of course if technically not better possible I would say that performance is more important than this detail but WDYT @jancborchardt @nimishavijay @marcoambrosini ?

No image sizes same as before. Scale means how image will display, size stays same(every image will have their own size like before) . You can see the difference from link below.

Scale Types

alperozturk96 avatar Feb 09 '24 12:02 alperozturk96

I guess that so many requests can lead the server to request the user to log in again. Either due to brute force protection, or token renewal. I would bet on the later. Can you share the request that fails and the data returned by the server?

REQUEST GET /owncloud/status.php Existence check for https://www.gisijoalma.de/owncloud/remote.php/dav/files/null/ targeting for existence finished with HTTP status 401(FAIL) Authentication method found: BASIC_HTTP_AUTH Creating OwnCloudClient REQUEST GET /owncloud/ocs/v2.php/cloud/capabilities

Successful response: {"ocs":{"meta":{"status":"ok","statuscode":200,"message":"OK"},"data":{"version":{"major":28,"minor":0,"micro":1,"string":"28.0.1","edition":"","extendedSupport":false},"capabilities":{"bruteforce":{"delay":0,"allow-listed":false},"spreed":{"features":["audio","video","chat-v2","conversation-v4","guest-signaling","empty-group-room","guest-display-names","multi-room-users","favorites","last-room-activity","no-ping","system-messages","delete-messages","mention-flag","in-call-flags","conversation-call-flags","notification-levels","invite-groups-and-mails","locked-one-to-one-rooms","read-only-rooms","listable-rooms","chat-read-marker","chat-unread","webinary-lobby","start-call-flag","chat-replies","circles-support","force-mute","sip-support","sip-support-nopin","chat-read-status","phonebook-search","raise-hand","room-description","rich-object-sharing","temp-user-avatar-api","geo-location-sharing","voice-message-sharing","signaling-v3","publishing-permissions","clear-history","direct-mention-flag","notification-calls","conversation-permissions","rich-object-list-media","rich-object-delete","unified-search","chat-permission","silent-send","silent-call","send-call-notification","talk-polls","breakout-rooms-v1","recording-v1","avatar","chat-get-context","single-conversation-status","chat-keep-notifications","typing-privacy","remind-me-later","bots-v1","markdown-messages","media-caption","session-state","note-to-self","recording-consent","sip-support-dialout","message-expiration","reactions","chat-reference-id"],"config":{"attachments":{"allowed":false},"call":{"enabled":true,"breakout-rooms":true,"recording":false,"recording-consent":0,"supported-reactions":["\u2764\ufe0f","\ud83c\udf89","\ud83d\udc4f","\ud83d\udc4d","\ud83d\udc4e","\ud83d\ude02","\ud83e\udd29","\ud83e\udd14","\ud83d\ude32","\ud83d\ude25"],"sip-enabled":false,"sip-dialout-enabled":false,"predefined-backgrounds":["1_office.jpg","2_home.jpg","3_abstract.jpg","4_beach.jpg","5_park.jpg","6_theater.jpg","7_library.jpg","8_space_station.jpg"],"can-upload-background":false,"can-enable-sip":false},"chat":{"max-length":32000,"read-privacy":0,"has-translation-providers":false,"typing-privacy":0},"conversations":{"can-create":false},"previews":{"max-gif-size":3145728},"signaling":{"session-ping-limit":200,"hello-v2-token-key":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE\/M\/H3frrF9P2OHhw0laIxERmukGN\ni9rAVZQKvAsUZYADn+l+z9vK\/1Zl35M89Lfa6r0mnE5gh4t886RIbn2i7g==\n-----END PUBLIC KEY-----\n"}},"version":"18.0.1"},"theming":{"name":"Nextcloud","url":"https:\/\/nextcloud.com","slogan":"ein sicherer Ort f\u00fcr all deine Daten","color":"#0082c9","color-text":"#ffffff","color-element":"#0082c9","color-element-bright":"#0082c9","color-element-dark":"#0082c9","logo":"https:\/\/www.gisijoalma.de\/owncloud\/core\/img\/logo\/logo.svg?v=2","background":"https:\/\/www.gisijoalma.de\/owncloud\/apps\/theming\/img\/background\/kamil-porembinski-clouds.jpg","background-plain":false,"background-default":true,"logoheader":"https:\/\/www.gisijoalma.de\/owncloud\/core\/img\/logo\/logo.svg?v=2","favicon":"https:\/\/www.gisijoalma.de\/owncloud\/core\/img\/logo\/logo.svg?v=2"}}}}}

I extracted those requests from log.

alperozturk96 avatar Feb 09 '24 13:02 alperozturk96

Codacy

Lint

TypemasterPR
Warnings6969
Errors33

SpotBugs

CategoryBaseNew
Bad practice6868
Correctness7272
Dodgy code351351
Experimental22
Internationalization77
Malicious code vulnerability22
Multithreaded correctness66
Performance5654
Security1818
Total582580

github-actions[bot] avatar Feb 17 '24 07:02 github-actions[bot]

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/12130.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

github-actions[bot] avatar Feb 17 '24 07:02 github-actions[bot]

blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.

github-actions[bot] avatar Feb 17 '24 08:02 github-actions[bot]

Out of date due to git conflicts and session time out problem

alperozturk96 avatar May 02 '24 12:05 alperozturk96