Android YogaLayout does not recalculate its dimension for any runtime change in children dimension #1168

Closed
opened 2022-10-19 07:31:01 -07:00 by SanthoshKandalu · 8 comments
SanthoshKandalu commented 2022-10-19 07:31:01 -07:00 (Migrated from github.com)

Report

Issues and Steps to Reproduce

Hi team,

We are facing a major issue with using YogaLayout android.

Issue:
Whenever the dimension of the child of YogaLayout changes dynamically, then the YogaLayout never recalculates its dimension for the change in child's dimension.
For.eg. Let us say we have a YogaLayout (with height/width = WRAP_CONTENT) has two children with ImageView (height/width = WRAP_CONTENT) and TextView (height/width = WRAP_CONTENT) in flex direction = Column. And we download the image from a url and load into the image view, when image is downloaded, then ImageView dimension changes, but the parent YogaLayout never adjusts its height and it renders the children in previously calculated height, as a result, the bottom text view gets cropped off.

I tried to mark the yogaNode of ImageView as dirty to re-render but no luck.

This issue has been haunting us for long time, and this is limits us to not to use YogaLayout as child of RecyclerView.

Please help

Expected Behavior

YogaLayout to recalculate its dimensions for any change in child's dimension

Actual Behavior

YogaLayout does not recalculate its dimensions for any change in child's dimension

Link to Code

If you have some code that maintainers can clone/test for themselves, bugs can be resolved much faster. Please paste a link here.

When applicable, use this fiddle to post a web repro.

# Report - [ .] I have searched [existing issues](https://github.com/facebook/yoga/issues) and this is not a duplicate # Issues and Steps to Reproduce Hi team, We are facing a major issue with using YogaLayout android. Issue: Whenever the dimension of the child of YogaLayout changes dynamically, then the YogaLayout never recalculates its dimension for the change in child's dimension. For.eg. Let us say we have a YogaLayout (with height/width = WRAP_CONTENT) has two children with ImageView (height/width = WRAP_CONTENT) and TextView (height/width = WRAP_CONTENT) in flex direction = Column. And we download the image from a url and load into the image view, when image is downloaded, then ImageView dimension changes, but the parent YogaLayout never adjusts its height and it renders the children in previously calculated height, as a result, the bottom text view gets cropped off. I tried to mark the yogaNode of ImageView as dirty to re-render but no luck. This issue has been haunting us for long time, and this is limits us to not to use YogaLayout as child of RecyclerView. Please help # Expected Behavior YogaLayout to recalculate its dimensions for any change in child's dimension # Actual Behavior YogaLayout does not recalculate its dimensions for any change in child's dimension # Link to Code ***If you have some code that maintainers can clone/test for themselves, bugs can be resolved much faster. Please paste a link here.*** ***When applicable, use this [fiddle](https://jsfiddle.net/emilsjolander/jckmwztt/) to post a web repro.***
NickGerleman commented 2022-10-19 20:05:01 -07:00 (Migrated from github.com)

Thanks for filing this. It's a bit tricky to tell what might be happening from your description. Would you be willing to provide a minimal repro of the issue?

To set expectations, the YogaLayout ViewGroup hasn't seen much attention recently, even compared to the overall layout engine, so we might not be able to give a quick turnaround for this issue.

Thanks for filing this. It's a bit tricky to tell what might be happening from your description. Would you be willing to provide a minimal repro of the issue? To set expectations, the `YogaLayout` ViewGroup hasn't seen much attention recently, even compared to the overall layout engine, so we might not be able to give a quick turnaround for this issue.
SanthoshKandalu commented 2022-10-22 21:13:55 -07:00 (Migrated from github.com)

@NickGerleman Thank you very much getting back

I have created a sample project here: https://github.com/SanthoshKandalu/YogaIssueDemo

  1. I have a created a simple YogaLayout with two children TextView and Button in flex direction column
  2. Initially the text view will show a simple single line text, on click of the button, I will try to show a bigger mulit-line text.
  3. But things don't go correct here, as you can see in the screenshot (second), the YogaParent does not recalculate its height and tries to render the views in the previously calculated height and as a result, button is cropped.
  4. The issue still persist even after marking the YogaNode for the text view as dirty
  5. This unexpected caused bigger problem when used in RecyclerView.

Can you please help?

Screenshot_20221023_094255,Screenshot_20221023_094310

@NickGerleman Thank you very much getting back I have created a sample project here: https://github.com/SanthoshKandalu/YogaIssueDemo 1. I have a created a simple YogaLayout with two children TextView and Button in flex direction column 2. Initially the text view will show a simple single line text, on click of the button, I will try to show a bigger mulit-line text. 3. But things don't go correct here, as you can see in the screenshot (second), the YogaParent does not recalculate its height and tries to render the views in the previously calculated height and as a result, button is cropped. 4. The issue still persist even after marking the YogaNode for the text view as dirty 5. This unexpected caused bigger problem when used in RecyclerView. Can you please help? ![Screenshot_20221023_094255](https://user-images.githubusercontent.com/50764274/197373378-8a31ce48-434d-49fd-b80d-887f6a49303a.png),![Screenshot_20221023_094310](https://user-images.githubusercontent.com/50764274/197373382-d8818d43-df92-4b1d-9207-d778b6706830.png)
woehrl01 commented 2022-11-12 05:59:32 -08:00 (Migrated from github.com)

@SanthoshKandalu it looks like you are not invalidating the parent like here. In order to kick of a layout recalculation for Android: 40db73d1a8/android/sample/java/com/facebook/samples/yoga/BenchmarkFragment.java (L42)

@SanthoshKandalu it looks like you are not invalidating the parent like here. In order to kick of a layout recalculation for Android: https://github.com/facebook/yoga/blob/40db73d1a8783eb72c73c55a6c99aac0b4e58a53/android/sample/java/com/facebook/samples/yoga/BenchmarkFragment.java#L42
SanthoshKandalu commented 2022-11-12 06:19:41 -08:00 (Migrated from github.com)

@SanthoshKandalu it looks like you are not invalidating the parent like here. In order to kick of a layout recalculation for Android:

40db73d1a8/android/sample/java/com/facebook/samples/yoga/BenchmarkFragment.java (L42)

@woehrl01 - Thanks for checking.

I tried that yet no luck. You can see the changes in line 38 of FirstFragment.kt in my demo app.

Can you please help?

> @SanthoshKandalu it looks like you are not invalidating the parent like here. In order to kick of a layout recalculation for Android: > > https://github.com/facebook/yoga/blob/40db73d1a8783eb72c73c55a6c99aac0b4e58a53/android/sample/java/com/facebook/samples/yoga/BenchmarkFragment.java#L42 @woehrl01 - Thanks for checking. I [tried](https://github.com/SanthoshKandalu/YogaIssueDemo/blob/6452885128fa26462e18181787a4182924b300ef/app/src/main/java/com/example/yogaissuedemo/FirstFragment.kt#L38) that yet no luck. You can see the changes in line 38 of FirstFragment.kt in my demo app. Can you please help?
woehrl01 commented 2022-11-12 10:06:17 -08:00 (Migrated from github.com)

Please try putting the text inside another container, just to verify if it doesn't hit a different error.

FYI: I haven't used Yoga inside Android, yet.

Please try putting the text inside another container, just to verify if it doesn't hit a different error. FYI: I haven't used Yoga inside Android, yet.
SanthoshKandalu commented 2022-11-12 20:42:46 -08:00 (Migrated from github.com)

Please try putting the text inside another container, just to verify if it doesn't hit a different error.

FYI: I haven't used Yoga inside Android, yet.

@woehrl01 - I tried to wrap the text inside another container - LinearLayout or YogaLayout, but same ui behaviour as the screenshot attached above.

> Please try putting the text inside another container, just to verify if it doesn't hit a different error. > > FYI: I haven't used Yoga inside Android, yet. @woehrl01 - I tried to wrap the text inside another container - LinearLayout or YogaLayout, but same ui behaviour as the screenshot attached above.
TChengZ commented 2023-03-15 03:03:10 -07:00 (Migrated from github.com)

Please try putting the text inside another container, just to verify if it doesn't hit a different error.
FYI: I haven't used Yoga inside Android, yet.

@woehrl01 - I tried to wrap the text inside another container - LinearLayout or YogaLayout, but same ui behaviour as the screenshot attached above.

i have the same problem, i use yogalayout as item in RecycleView,and the item seem to be clipped as above, do u have any solution?

> > Please try putting the text inside another container, just to verify if it doesn't hit a different error. > > FYI: I haven't used Yoga inside Android, yet. > > @woehrl01 - I tried to wrap the text inside another container - LinearLayout or YogaLayout, but same ui behaviour as the screenshot attached above. i have the same problem, i use yogalayout as item in RecycleView,and the item seem to be clipped as above, do u have any solution?
NickGerleman commented 2023-04-25 20:44:34 -07:00 (Migrated from github.com)

We're deprecating the com.facebook.yoga.android.YogaLayout ViewGroup in the next major release of Yoga. We intend to still push out a new version aligned to the core Yoga 2.0. I have bulk closed ViewGroup issues to reflect that we are not planning to invest time into functional changes of the ViewGroup. and eventually intend to remove it from the repo.

We're deprecating the `com.facebook.yoga.android.YogaLayout` ViewGroup in the next major release of Yoga. We intend to still push out a new version aligned to the core Yoga 2.0. I have bulk closed ViewGroup issues to reflect that we are not planning to invest time into functional changes of the ViewGroup. and eventually intend to remove it from the repo.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DaddyFrosty/yoga#1168
No description provided.