androidx / constraintlayout

ConstraintLayout is an Android layout component which allows you to position and size widgets in a flexible way
Apache License 2.0
1.07k stars 176 forks source link

Suspected bug in optimizer #422

Open jswong65 opened 2 years ago

jswong65 commented 2 years ago

I simplified the bug to this layout and observed. This is related to some other reported issues.

https://github.com/androidx/constraintlayout/issues/397 https://github.com/androidx/constraintlayout/issues/411 https://github.com/androidx/constraintlayout/issues/421


    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tool="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#cff"
    tool:parentTag="androidx.constraintlayout.widget.ConstraintLayout">

    <TextView
        android:id="@+id/b"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:layout_marginRight="280dp"
        android:background="#8f0f"
        android:text="abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdef"
        app:layout_constraintWidth_default="wrap"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <androidx.constraintlayout.widget.Barrier
        android:id="@+id/barrier"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:barrierDirection="bottom"
        app:constraint_referenced_ids="b"/>

    <View
        android:layout_width="0dp"
        android:layout_height="10dp"
        android:background="#8fe6"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@id/barrier"/>

</androidx.constraintlayout.widget.ConstraintLayout>```
sunilcnair commented 2 years ago

Hi All, I also recently updated to 2.1 and my app UI is also broken.
I am creating customview inheriting from constraint layout. vertical view is not getting rendered properly.

few libraries have updated to 2.1 and we have dependency moving to latest constraint layout due to this.

Kindly let me know if this bug is fixed in the latest release?

sunilcnair commented 2 years ago

@camaelon @jswong65 can we know when will this defect be fixed.

jafu888 commented 2 years ago

This will not be fixed in this release cycle. It will probably be addressed mid year next year.

I suggest setting app:layout_optimizationLevel="none" Internally the fix will be to detect the situation and turn off the optimizer.

pedrofsn commented 1 year ago

app:layout_optimizationLevel="none" works here!