I've got several UIViews that have a layer class of CATiledLayer because they need to be zoomed using UIScrollViews. I use Quartz to render some PDF pages inside said UIViews. Everything is fine until I try to animate said views frames on page rotation.
The animation is fine, the contents of the view gets scaled quickly and cheaply to match the new frame size. After the animation I call setNeedsDisplay to re-render the whole thing. Now before my -(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)ctx get's called (but after setNeedsDisplay) the views contents shortly reverts back to the previous state (with the remaining pixels being stretched edge pixels in cases where the contents becomes smaller than the view). This results in a flash of some very annoying graphical distortion before reverting back to normal thanks to the new "render pass".
After a lot of debugging I've managed to sort out that this definitely happens during the actual drawing cycle (rather than the application run cycle where I do setNeedsDisplay) but before -(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)ctx even gets called.
What's the sanest way of avoiding or further debugging this?
Edit: I've thrown together a very simple project that demonstrates this effect perfectly. http://dl.dropbox.com/u/1478968/EEBug.zip PS: There's a sleep(2) in the rendering code just so that the effect could be better observed on screen.