Slide 1

Slide 1 text

Tuning for Speed iOS Book club Jasdev Singh

Slide 2

Slide 2 text

CPU and GPU → GPU is optimized for the sort of highly parallel floating point math. → CPU can perform arbitrary computations.

Slide 3

Slide 3 text

Stages of Core Animation → Layout: Prepare view/layer hierarchy and set up the properties of the layer. → Display: Backing images are drawn (drawRect(_:) or drawLayer(_:inContext:)) → Prepare: CD gets ready to send the animation data to the render server (Backboard). → Commit: Final phase where CA packages up and sends the layers and animation properties.

Slide 4

Slide 4 text

Stages of Core Animation Cont. → Render server deserializes data to form render tree → For each frame of the animation: → Calculates the intermediate values for all of the layer properties → Renders the visible triangles to the screen (GPU)

Slide 5

Slide 5 text

Factors that Slow Layer Drawing (GPU- Bound Operations) → Too much geometry → Too much overdraw--caused by overlapping semitransparent layers (finite fill-rate). → Offscreen drawing--occurs when an effect cannot be achieved by directly drawing onto the screen (rounded corners, layer masks, etc.) → Too-large images

Slide 6

Slide 6 text

Factors that Slow Start of the Animation (CPU-Bound Operations) → Layout calculations for complex view hierarchies → Lazy view loading (e.g. loading from a nib file or Storyboard) → Core Graphics drawing (drawRect(_:)). Backing image is created in memory with the same size of the view. → Image decompression

Slide 7

Slide 7 text

Testing → Always test on a device, the simulator won't give an accurate representation of performance. → Test with Release configurations to take advantage optimizations

Slide 8

Slide 8 text

Instruments → Time Profiler → Core Animation → OpenGL ES Driver (used to debug GPU performance issues)

Slide 9

Slide 9 text

Time Profiler → Used to monitor CPU usage. → Separate by thread and hide system libraries

Slide 10

Slide 10 text

Core Animation Instrument → FPS breakdown → Color blended layers (common source of overdraw) → Color hits green and misses red (when using shouldRasterize) → Color copied images (highlights images that have to be copied to the render server)

Slide 11

Slide 11 text

Core Animation Instrument Cont. → Color immediately (draws debug colors immediately) → Color misaligned images (nonintegral coordinates) → Color offscreen-rendered yellow → Color OpenGL Fast Path Blue → Flash updates regions (redrawn content)