Jetpack Compose LazyVerticalGrid + coil lag - android

So i'm using LazyVertialGrid alongside coil to display some images, i have 3 fixed columns but whenever i scroll it gets pretty stuttery, almost unusable.
Am i doing something wrong or missing something?
I tried release mode, and lowering coil images resolution with no performance changes whatsoever.
I even commented the asyncImage line to see if coil was the problem, but even scrolling wasnt %100 smooth.
Edit1:
I checked the logs and saw this: https://gyazo.com/f292139703889495e5b4d385e170f425
Heres a video example of it: https://gyazo.com/ed7b4a9c7e1f4f256ad683d719ed62a7
I noticed that everytime i scroll down or up coil checks and tries to load an image (the loading icon), how do i prevent this behavior?
Edit2: Heres the code part of my lazyverticalGrid:
https://gyazo.com/14262effe8a2f6aa48b45fd1a7f7bb41

Related

Frames Skipping while working with Android Animation

I have two fragments on the same screen. One is changing image after every 3 seconds and the other is showing a text with a horizontal animation (from left to right). The image fragment is setting the image from external memory using the method setImageURI.
The problem occurs when a new image is loaded in the view, animated text on the other fragment skips its frames and a kind of glitch appears on that fragment interface.
I have tried changing the image on a Runnable thread as well but that didnt work as well.
Can anyone suggest something better?
And also....can the problem be resolved using a device with a better RAM?

Fresco Image with both width and height - match_parent doesn't display

I have an app which loads an image using the fresco library. I have 2 problems.
1. If I use the fresco image like this
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/feedImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
it won't display anything but a thin line of colors where the image should be.
However if I do something like
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/feedImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
fresco:viewAspectRatio="1.33"
android:scaleType="fitXY"
/>
everything is working fine(but I don't see the full image).
I want to achieve the same view as facebook(images full width and height).
I load the images in a list in a recycler. The images are loaded into cache(I verified that) but if I go all the way down and then back up I can see the images being loaded(facebook doesn't have this problem and they use the same library). If I scroll really slow there is no problem. I recently changed from volley and I did not have this problem before(so it's not the recycler). How can I solve this ?
Edit: And something else that I noticed is that if I disable the disk cache and kill the app the cache is not deleted as the documentation says. I know that if I call ImagePipeline imagePipeline = Fresco.getImagePipeline(); Uri uri; imagePipeline.evictFromMemoryCache(uri); the cache will be deleted, but shouldn't this be automatically ?
So for problem #2 I am not entirely sure I understand the problem correctly it isnt a problem at all. The image may very well be in memory cache, however the image stored in cache still needs to be decoded before it can be displayed on screen, which is probably that loading issue you speak of. The reason you only see this when scrolling through quickly is because the RecyclerAdapter that you are using is catching up to the scroll position.(this is an educated guess, by no means should this be assumed to be correct). When you move slowly and dont see the image loading is because the Adapter starts to load the next ViewHolder before it is on screen, but not much before that point. SO when you scroll quickly I believe it is simply the Adapter playing catching up with its OnBindViewHolder call, as opposed to moving through slowly it doesnt need to play catch up and has the image loaded before you reach the next item in the recyclerview.
The disk cache is not cleared when the app is backgrounded like memory cache, so if needed you will need to evict it.
I am not sure about issue #1 but I will try to find out why that may be. Maybe try setting the scaletype to CropCenter or something and see if that rids you of the lines.

How to cope with jitter when using Android-Universal-Image-Loader in a ListView?

I'm using Android-Universal-Image-Loader in a ListView of mine and I'm trying to find the best solution to following:
using resetViewBeforeLoading is necessary or else I get the same image in my ConvertViews, but this causes jitter, unless..
I use PauseOnScrollListener which is otherwise great, except that it shows a blank in some ConvertViews even for images that are already downloaded (I'm using memory and disk caches), so it's confusing to the user who sees a blank for an image they saw only 2 swipes ago
So it seems that I can't get an instant image load (for already-downloaded images) on scroll without jitter, even for images in memory, is this about right? Is there a better or more standard way to do this? (Vertical list-view showing screen-width images, sort of like the Instagram app, which does it buttery-smooth)
Otherwise, is there a way to lengthen the number of convertViews in my ListView to prevent unnecessarily aggressive re-use?
Thanks in advance

Large images (from file) not loading in Picasso, no obvious error seen

I'm writing an app which gets a list of the images from the gallery on a device and then shows them in a GridView. In my adapter I have the following code (where the width and height are those of the view it will be placed in):
PicassoSingleton.with(mContext).load("file://" + imageUri).resize(getImageWidth(), getImageHeight()).centerInside().placeholder(R.drawable.image_placeholder).error(R.drawable.image_error).into(holder.image);
On most devices this works really well. However, on some devices where the photos taken are very large (such as the Samsung Galaxy S5- 16MP) some images do not load, and the error resource is displayed. I do not see any obvious log messages from Picasso debugging, only the following:
D/Picasso(20171): Main errored [R7]+501ms
I presume this is due to memory issues, but I am not sure how to go about fixing these. Is it possible to tell Picasso to compress the images? Or is there something else I'm missing?
Thanks
This issue appears to be linked to https://github.com/square/picasso/issues/539
Updating to the latest version of Picasso (here 2.3.3-SNAPSHOT) fixed this

Android transparent png shadow rendering poorly

I am testing a mobile site at the moment on android and have noticed that all my transparent images that have a shadow at the bottom are all rendering extremely poorly. I have tried adding noise>0.5>uniform>monochromatic to the image to solve this but this hasnt helped at all i also tried adding noise>2.0>gausiann>monochromatic but again got no change.
its clear that the image is being rendered as png8 even though im saving out the image as png24. i am also using the most up to date version of the android browser 2.3.3
Can anyone shine any light on this problem?
I know its old but the solution is here.
To summarize: Use following code in onCreate(), between super.onCreate() and setContentView() in your activity:
getWindow().setFormat(PixelFormat.RGBA_8888);

Categories

Resources