readium / SDKLauncher-iOS

A small iOS application to serve as a launcher/testbed for the Readium SDK.
BSD 3-Clause "New" or "Revised" License
71 stars 47 forks source link

Book load and page load time is slow compared to iBooks #76

Closed msintov closed 8 years ago

msintov commented 8 years ago

We have internally built this epub with PubCoder: https://www.dropbox.com/s/lnili0x5kofle2v/Invasion_of_the_Space_Monkeys_v2.epub?dl=0

With SDKLauncher-iOS (I'm using the WKWebView branch) on an iPad 2 running iOS 9.2.1, I select my book, then select "Table of Contents" and "Chapter 1" to open to the first page.

It takes between 3.5 and 4.5 seconds for the first page to render after tapping "Chapter 1". According to Instruments Time Profiler, the bulk of the time is roughly spent in these areas: GCDAsyncSocket completeCurrentRead Core Animation, various methods

Turning pages also takes over 2 seconds per page until the page is rendered.

iBooks shows significantly better performance for turning pages on this same device. The page turning appears instantaneous. The initial book load also is smoother however iBooks has a different user experience (as it first shows the first page, then a loading spinner, then page 1).

Could you recommend how I can improve SDKLauncher-iOS book load and page turn time? Here are some ideas I am considering. Perhaps you can help point me in the right direction:

Thank you for any pointers!

danielweck commented 8 years ago

Hello, there is the feature/prefetch branch in readium-shared-js, but it's only an experiment. I have seen multiple webview experiments, but the difficulty is in

danielweck commented 8 years ago

...difficulty is in setting up the content to preload, using a duplicate "background" Readium context, or by prefetching spine items (without messing up bookmarks, video/audio playback, etc.)

2s lag is way overkill though...we need to test your EPUB.

rkwright commented 8 years ago

Could this be relevant? From Olivier Korner (@olivierkorner) I noticed that the iOS and Android, the RDPackageResourceServer or EpubServer, the Cache-Control / Last-Modified and Expires HTTP headers are not set. Adding these headers to each resource request would allow the pages and the assets to be cached be the webviews. Caching reused images or fonts may provide a significant boost the rendering speed of the pages.

I ran some tests, with and without headers, in UIWebView and WKWebView, on iOS on an iPad and the results show the rendering time can be reduce by 10 to 30%. Also, I'm sure someone's already ran tests to compare UIWebView vs. WKWebView on iOS but I was very interested to see a 30 to 50% gain of rendering speed by combining WKWebView with the cache control headers.

table
HadrienGardeur commented 8 years ago

HTTP/2 might also help in the future: https://www.mnot.net/blog/2016/04/22/ideal-http

msintov commented 8 years ago

I was able to fix this issue by using the Cache-Control headers and fixing some problems with our epub. Thank you!