Search code examples
iosuiscrollviewcore-animationxcode-instruments

Bottleneck in CA::Transaction::commit()


When using the Time Profiler on interactions with a UIScrollView (containing many subviews) I often see CA::Transaction::commit() in the heaviest stack trace. What is this method and how can I spend less time in it?

Screenshot

My educated guess is that this is how Core Animation layers are sent to the GPU and that this could be sped up by reducing the dimensions of and/or number of CALayers that must be rendered (i.e. the amount of data that must be sent to the GPU).


Solution

  • Your guess could be correct. Bare in mind that following things are typically also done in the CATransaction::commit()

    • Layouting of CALayers: layoutSublayers, preferredFrameSize, CALayoutManager
    • all CAActions
    • sometimes also the rendering of the various filter-properties of a CALayer
    • probably the layouting of the subviews in your scroll-view