9.2 · From layout to the GPU, and the two layer trees
Your app does not draw to the screen. It builds a tree of layers and hands it to another process, which composites it with the GPU. Knowing the stages tells you where a slow frame was lost.
Mental model. A frame is a pipeline across two processes: your app prepares the description of the frame, and the render server draws it. You can be slow in either half.
The pipeline
The stages of one frame and who does what.
- Walk through how a frame gets from your code to the screen.
A frame has two halves. In your process, the Core Animation commit happens at the end of the current run-loop turn (a run-loop observer drives it). It has four…
Layer trees
Model tree, presentation tree and backing stores.
- What are the model, presentation and render layer trees, and how do the layer geometry properties relate?
Core Animation keeps three trees. The model tree is the layers you create and configure; reading layer.opacity gives the target value as you last set it. The…
More in Layout, rendering & animation
- 9.1 · Auto Layout, intrinsic size, and when layoutSubviews and draw run
- 9.3 · Offscreen passes, rasterization, blending, shadows and masks
- 9.4 · Implicit and explicit animation, UIView animation, and animators
- 9.5 · Core Graphics, UIBezierPath and draw(_:)
- 9.6 · TextKit 1 and 2, and Text in SwiftUI
- 9.7 · Frame budgets, ProMotion, hitches and hangs
- 9.8 · Margins, stack views, guides, constraint ownership, the layout cycle and measuring
- 9.9 · Coordinate conversion, 3D transforms and layer contents
- 9.10 · How UIView animation really works, springs, timing and display links
- 9.11 · Transform order, fill rules, text measurement, text containers and bitmaps
- 9.12 · Rectangle containment and moving a point between coordinate spaces