I have been looking at layout performance of Facebooks Yoga layout (https://facebook.github.io/yoga/
) and Androids RelativeLayout in Android apps. While the Yoga layout is not fully featured yet (eg. it misses support for baseline alignment) it has one thing going for it: speed
The attached screenshot shows the same layout using nested Yoga layouts and nested RelativeLayouts. While the RelativeLayout is know to be notoriously slow when nesting deep it was still an interesting observation:
When nesting the RelativeLayout 16 layouts deep, starting the app took 22 sec
(Nexus 6p). Layouting 16 levels deep with Yoga took only 2,7 sec
. That is nearly 10 times better performance.
So where is the limit for the yoga layout? In fact there is no limit. The only limit is a crash in the jni layer when going very deep. Until that point the performance does not deteriorate noticable from nesting deeper.
So how far can you take it? The maximum number of nested layouts was 500 ViewGroups. The startup time of the app remains at ~2.7 sec
. Pretty impressive.
So comparing layout performance between Androids RelativeLayout and the Yoga layout in the shown scenario is clearly in favor of the Yoga layout. It would be interesting to pit the Yoga Layout against the ConstraintLayout.
cc +Lucas Rocha