Profile

Cover photo
Matthew Bishop
Attends University Of Utah
Lives in Salt Lake City, Utah
713 followers|13,507 views
AboutPostsPhotosVideos

Stream

 
Merge a fetch & into request?

I was wondering if this is already possible, and if not how difficult it might be to add.

I have an "infinite scrolling" style view pager that shows user profiles. On each profile page is relatively large (say 500x500 pixels on a Nexus 4) image of the user. As the user approaches the end of the already loaded profiles, I make a request for an additional set of profiles. When I receive the additional profiles, I go through and use Picasso to *fetch* the images for all the users I just downloaded.

Then, when the user swipes into the new set of users I use Picasso like normal to load the images *into* a Target. Hopefully they should now be cached either in memory or on disk, so this is fast.

I don't fully understand the internals -- but it seems like if the user gets to new profiles before the fetch has completed, a new request is made instead of piggy backing off of the (probably nearly completed) fetch request.

So my question: is there any way to "merge" the *fetch* and *into* requests so that the prefetching doesn't get dropped on the floor?

By the way, does this question make any sense or is there a better way to achieve what I'm looking for?
1
Dandre Allison's profile photoDimitris Koutsogiorgas's profile photoJake Wharton's profile photoMatthew Bishop's profile photo
5 comments
 
Hi +Dimitris Koutsogiorgas and +Jake Wharton, this might be a little too device / situation specific for you to answer, but the *tl;dr; is that I added logging to OkHttpDownloader and I'm getting results like*:

D/OkHttpDownloader(23322): OkHttpDownloader.load(Uri = http://graph.facebook.com/1212197/picture?height=320&width=320&migration_overrides=%7Boctober_2012%3Atrue%7D)
D/OkHttpDownloader(23322): took 22206 milliseconds
D/OkHttpDownloader(23322): From CACHE 200

This is an image that I prefetched, so basically it's taking 22 seconds to load a 320x320 image from the cache. That seems unusual to me. Plus if for some reason that's hitting the network it's on WiFi so that still seems slow for such a small image.

I wish I could use Traceview to figure out exactly what the problem is -- unfortunately it's manifesting itself on the only device used by my client (a Nexus S). By the way, I don't see the same problem on my Nexus One (which is more than a year older than the Nexus S), so I don't think it's simply device performance related.

I checked out the master branch from Github and added some logging to OkHttpDownloader to see if the problem is in the network, or OkHttp, or somewhere else (i.e my code). Logging code & and example of the problem from the logs I had the client send me:

https://gist.github.com/bishopmatthew/6719532

Notice the java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer) exception? Does that just mean my client is on a really shitty connection? And obviously there are some slow network requests in there:

D/OkHttpDownloader(23322): OkHttpDownloader.load(Uri = https://scontent-b.xx.fbcdn.net/hphotos-frc3/s320x320/827_10151160068811861_387770408_n.jpg)
D/OkHttpDownloader(23322): took 26232 milliseconds
D/OkHttpDownloader(23322): From NETWORK 200

But there's also slow cache calls too, like the first one I showed you or this one:

D/OkHttpDownloader(23322): OkHttpDownloader.load(Uri = http://graph.facebook.com/1526100/picture?height=80&width=80&migration_overrides=%7Boctober_2012%3Atrue%7D)
D/OkHttpDownloader(23322): took 10031 milliseconds
D/OkHttpDownloader(23322): From CACHE 200

Basically -- can I just chalk this up to a slow device and slow network connection or could there be something more happening (especially with the disk cache)?
Add a comment...

Matthew Bishop

Shared publicly  - 
 
So, space is awesome. I wish we spent more money on making all my science fiction dreams come true.

See what cutting NASA's funding is doing to the poor astronauts.

http://www.astronautsuicides.com/
(drag the little black bar near the bottom of the picture to scroll)
1
Hayden Davis's profile photoMatthew Bishop's profile photo
2 comments
 
Ha, getting caught up on your TV? And are you going back to BYU in the fall? We'll have to meet up and catch up sometime.
Add a comment...
Have him in circles
713 people
Michael Chaudhary's profile photo

Matthew Bishop

Shared publicly  - 
 
One of those great This American Life podcasts. Makes me wanna give them money (again).
Alexis Ohanian originally shared:
 
The more light we can shine on this broken patent system, the better. Software patents suck.
1
Jessi Sawyer's profile photoMatthew Bishop's profile photoJase Cutler's profile photo
4 comments
 
Ha, +Jessi Sawyer , where do you get your non-rage-inducing news? It would be good for my stress levels and blood pressure.
Add a comment...
People
Have him in circles
713 people
Michael Chaudhary's profile photo
Places
Map of the places this user has livedMap of the places this user has livedMap of the places this user has lived
Currently
Salt Lake City, Utah
Previously
Nampa, Idaho - Salt Lake City, Utah
Links
Education
  • University Of Utah
    Computer Science, 2010 - present
  • Utah Valley University
    -, 2005 - 2008
  • Brigham Young University
    Mechanical Engineering, 2008 - 2009
Basic Information
Gender
Male