Page MenuHomePhabricator

High res gallery images are fetched on app restart causing poor performance - switch to lazily fetching high res gallery images
Closed, ResolvedPublic

Description

This is ultimately fallout from the WKWebView update - had to change how we dealt with saved pages images pretty drastically.

Repro:

  • checkout 5.0.4
  • clean install to simulator
  • start at obama, save the article,
  • go back through previous 8 presidents saving them as well
  • stop app
  • checkout 5.0.5
  • start charles proxy
  • run 5.0.5 on top of old 5.0.4 data

For the steps above charles proxy indicated that, on startup...

  • 403 images were fetched
  • 75 image info queries were sent
  • ~511 MB of data was transferred

Proposed fix:

  • on save only save MWKArticle's "imageURLsForSaving" (these are all the images the article actually used at the resolution it used them) and let the gallery lazily fetch 1280px high res images only when that image is actually displayed in gallery

Extra credit:

  • consolidate image info queries - run one query passing it list of all images we're wanting info about instead of doing separate query for each image

Event Timeline

More numbers for "enwiki > San francisco" article on clean install:

5.0.4
pre save 15 images @ 492KB
post save 175 images @ 22MB
post restart 205 images @ 98.8MB

5.0.5
pre save 15 images @ 492KB
post save 128 images (smaller 'cause we're not fetching unused srcset variants any more!) @ 20.1 MB
post restart 153 images @ 91.2 MB

( Note: these numbers are for images appearing in SDWebImage's cache folder - "com.hackemist.SDWebImageCache.default" )

Mhurd renamed this task from 5.0.5 Saved pages startup sync is refetching large amount of images to 5.0.5 Saved pages startup sync is refetching large amount of images - switch to lazily fetching high res images.Jul 22 2016, 9:30 PM
Mhurd updated the task description. (Show Details)
Mhurd renamed this task from 5.0.5 Saved pages startup sync is refetching large amount of images - switch to lazily fetching high res images to High res gallery images are fetched on at app restart causing poor performance - switch to lazily fetching high res gallery images.Jul 22 2016, 9:32 PM
Mhurd renamed this task from High res gallery images are fetched on at app restart causing poor performance - switch to lazily fetching high res gallery images to High res gallery images are fetched on app restart causing poor performance - switch to lazily fetching high res gallery images.
Mhurd updated the task description. (Show Details)
Mhurd updated the task description. (Show Details)

@Mhurd is this still the case? I know we changed caching stuff a couple times, so just want to conifrm if this is still needed and or merged.

@JMinor yes this is still the case. the image caching bits are *much* more sane than formerly, however, the high res images are not being fetched lazily and are indeed only fetched on app restart, which basically grinds everything to a halt the next time you restart the app if you're on a slower network :(