Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is this CATiledLayer/PDF code slow?
    text
    copied!<p>Here is the code:</p> <p><a href="https://www.dropbox.com/s/o42wy36x4qhrbpt/PDFScroller.zip" rel="nofollow noreferrer">https://www.dropbox.com/s/o42wy36x4qhrbpt/PDFScroller.zip</a></p> <p>I took the WWDC 2010 <code>PhotoScroller</code> sample code that implements nested <code>UIScrollViews</code> for zooming, inside a <code>UIScrollView</code> for paging, and swapped out what I thought would be minimal amount of code required for displaying a multi-page PDF instead of images.</p> <p>It works. But it's slow on my iPhone4, about three seconds to paint the first page, and even slower on my iPod Touch. I can watch it painting the individual tiles. This same PDF already opens up more quickly, with no visible tile drawing, in an alternate <code>CATiledLayer</code> implementation I have which simply uses a single <code>CATiledLayer</code>/<code>UIScrollView</code> and touch events to change pages. I'd like to use this <code>PhotoScroller</code> technique, it's very nice.</p> <p>I watched it with CPU Sampler in Instruments, and it doesn't seem to be the PDF rendering code, it looks like the time is taken up in threading and messaging. I'd appreciate it if someone could help point out what this sample is doing to incur the overhead.</p> <p>Thanks,</p> <p>Jim</p> <hr> <p>Update 1: I had originally used the <code>TilingView</code> class technique from the sample code of defining</p> <pre><code>+ (Class) layerClass { return [CATiledLayer class]; } </code></pre> <p>And then drawing in <code>- (void)drawRect:(CGRect)rect</code> but switched to the explicit <code>CATiledLayer</code> subclass as a first attempt at seeing whether it would make a difference, but it did not, and so I left the code as-is for posting here. There is also a missing <code>[tiledLayer release];</code> leak in TilingView.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload