ConstraintLayout onMeasure very slow ConstraintLayout onMeasure very slow xml xml

ConstraintLayout onMeasure very slow


That's definitely not expected -- I'll have to investigate more to see what's causing it. Note that 1.1 beta is right now going to be slower than 1.0, all the optimizer passes aren't enabled. At first glance there's a lot of textview with 0dp width, which is pretty costly -- like with linear layout, 0dp is going to result in a double measure. E.g. instead of:

<TextView    android:id="@+id/order_list_item_order_title"    android:layout_width="0dp"    android:layout_height="20dp"    android:layout_marginTop="4dp"    android:text="@string/main_swipe_list_item_info_title_order"    app:layout_constraintEnd_toEndOf="@id/mid_guideline"    app:layout_constraintStart_toStartOf="@id/start_guideline"    app:layout_constraintTop_toBottomOf="@+id/delivery_status"/>

You could do:

<TextView    android:id="@+id/order_list_item_order_title"    android:layout_width="wrap_content"    android:layout_height="20dp"    android:layout_marginTop="4dp"    android:text="@string/main_swipe_list_item_info_title_order"    app:layout_constraintStart_toStartOf="@id/start_guideline"    app:layout_constraintTop_toBottomOf="@+id/delivery_status"/>

You don't need to have both a start and end constraints here as well, as you are using guidelines.

Note that in general, HierarchyViewer isn't going to be giving you accurate measurements (that said with such a difference, something seems wrong there).

How does your com.express.mobile.customView.MyNetworkImageView custom view handles measures? as you set it to 0dp it will also be double-measured in your layout.

Finally, Could you add what's in your included layout order_list_item_map_interval_box ?

edit 1.1 beta 6 should improve performances quite a log


Just tried ConstraintLayout 1.1.0-beta6Measure times has been cut down to around 250ms.Roughly it's faster by 40% but far from being useful in my situation.


I believe someone posted in a comment that a non-release version of the apk will run much slower. I just confirmed it on my own app. The simple page would load very slowly and a button click would run CPU usage up to 25% using a debug app. Making a release build solved the issue.

The ConstraintLayout must be communicating heavily in the background, and those logs or callbacks are probably getting stripped when running a release build. Good luck!