CALayer loses rasterization when scrolled offscreen in a UIScrollView
I've got some nice custom UIViews that use CALayers for some fairly elaborate masks and transparencies. It took me a while to figure out how to make it run smoothly, but I found that by wrapping relevant objects in a container UIView, and setting the container's layer.shouldRasterize to YES, but leave that property of all the contained views set to NO, it will run buttery smooth no matter how elaborate your blending may be.

It's basically like this:


UIScrollView
***
Container View (layer.shouldRasterize = YES)

   - child (layer.shouldRasterize = NO)
     - childOfChild (layer.shouldRasterize = NO)
   - child (layer.shouldRasterize = NO)
   - child (layer.shouldRasterize = NO)

Container...

Container...(and so on)
***

Basically, the container ends up as one big block image when it rasterizes, minimizing the amount of rasterization that has to be done. However, this has created a new problem for me. If I have several containers in a UIScrollView, as soon as one of the containers gets scrolled offscreen, it gets tagged "Red" in the CoreAnimation profiler, and therefore must be rendered again when it is scrolled back onscreen. This causes a brief stutter. I don't understand why the container's layer has to rasterize all over again. Can anyone explain this or perhaps provide a workaround? Thanks.
CALayer loses rasterization when scrolled offscreen in a UIScrollView
===

I've got some nice custom UIViews that use CALayers for some fairly elaborate masks and transparencies. It took me a while to figure out how to make it run smoothly, but I found that by wrapping relevant objects in a container UIView, and setting the container's layer.shouldRasterize to YES, but leave that property of all the contained views set to NO, it will run buttery smooth no matter how elaborate your blending may be.

It's basically like this:


UIScrollView
***
Container View (layer.shouldRasterize = YES)

   - child (layer.shouldRasterize = NO)
     - childOfChild (layer.shouldRasterize = NO)
   - child (layer.shouldRasterize = NO)
   - child (layer.shouldRasterize = NO)

Container...

Container...(and so on)
***

Basically, the container ends up as one big block image when it rasterizes, minimizing the amount of rasterization that has to be done. However, this has created a new problem for me. If I have several containers in a UIScrollView, as soon as one of the containers gets scrolled offscreen, it gets tagged "Red" in the CoreAnimation profiler, and therefore must be rendered again when it is scrolled back onscreen. This causes a brief stutter. I don't understand why the container's layer has to rasterize all over again. Can anyone explain this or perhaps provide a workaround? Thanks.