离屏渲染 Offscreen rendering
Instruments
1、打开方式
打开Instruments.png
图片.png
图片.png
2 触发方式
The biggest bottlenecks to graphics performance is offscreen rendering and blending – they can happen for every frame of the animation and can cause choppy scrolling.
Offscreen rendering (software rendering) happens when it is necessary to do the drawing in software (offscreen) before it can be handed over to the GPU. Hardware does not handles text rendering and advanced compositions with masks and shadows.
The following will trigger offscreen rendering:
-
Any layer with a mask (
layer.mask) -
Any layer with
layer.masksToBounds/view.clipsToBoundsbeing true -
Any layer with
layer.allowsGroupOpacityset to YES andlayer.opacityis less than 1.0
When does a view (or layer) require offscreen rendering? -
Any layer with a drop shadow (
layer.shadow*).
Tips on how to fix: https://markpospesel.wordpress.com/tag/performance/ -
Any layer with
layer.shouldRasterizebeing true -
Any layer with
layer.cornerRadius,layer.edgeAntialiasingMask,layer.allowsEdgeAntialiasing -
Any layer with
layer.borderWithandlayer.borderColor?
Missing reference / proof -
Text (any kind, including
UILabel,CATextLayer,Core Text, etc). -
Most of the drawing you do with
CGContextindrawRect:. Even an empty implementation will be rendered offscreen. -
阴影开启shadowPath wwdc 2014 session 419里有相应介绍