0

I have a GridView with thumbnail images loaded in a separate thread. After all the thumbnails are done loading, if I scroll the grid view it's consistently slow (~5fps), until I scroll a few rows down, then it immediately scrolls extremely fast (~30fps) even if I scroll all the way up again.

If I then repopulate the gridview, it's slow again until I scroll down some more. It's not an issue of recycling the views as I am already doing that.

(Update: uploaded the correct slow trace image)

I tracked the issue to an internal view draw call. Here is the Android Studio trace for when it's slow:

slow trace

And here is the trace for when it's fast:

fast trace

It's clear the guilty method is android.view.ThreadedRenderer.draw(), but this is an internal call and I can't test further. From the trace, my understanding is that it's not the drawing that is slow, as the android.view.ThreadedRenderer.updateRootDisplayList() which eventually calls android.widget.AbsListView.draw() finishes just as quickly in both traces. So it must be the rest of the android.view.ThreadedRenderer.draw() that is causing this.

Looking online I found the ThreadedRenderer.java class

Things I've tried:

  • Forcing hardware rendering on the gridview made no difference.

  • Forcing software rendering on the gridview made the list always scroll very slowly.

Any ideas why this could be happening?

manixrock
  • 2,533
  • 4
  • 24
  • 29

2 Answers2

0

Well, the reason that it's a lot faster to scroll after the first time is that Android is recycling views. This means that it's taking the most time to construct the views initially.

I think you're going a bit too deep. You should check to make sure you're not downloading the thumbnails synchronously during draw. Try removing the code that downloads the images, or set the URLs to "". Essentially, try stripping down your thumbnail view until you can pinpoint what the issue is. This should help set you on the right track.

Oleg Vaskevich
  • 12,444
  • 6
  • 63
  • 80
  • I don't think it's an issue with recycling the views as I am already doing that. Plus I am waiting for ~20 seconds before I start scrolling, and it's not scrolling slowly only when showing a new row of cells, but always. – manixrock May 19 '15 at 15:06
  • The thumbnails are all downloaded in a separate thread, and I am logging the thumbnails loading and adapter `getView()` calls, and they are all extremely fast. No thumbnails are loading while I scroll, they are all loaded into memory before that, and only assigned to the cell Image view inside the adapter `getView()` call. – manixrock May 19 '15 at 15:08
  • Hmm, it's kind of hard to tell without seeing any of your code. What happens if you replace your thumbnail view with just a regular TextView? Also, have you tried on other devices/emulators (genymotion)? – Oleg Vaskevich May 19 '15 at 15:30
0

I had a similar problem recently. You need to check the number of Layouts in your xml file.

The more relative or linear layouts you have on your scroll view the more slow it gets.

Post your xml file less see.