[Android] Call handleUpdateLayout even if the content didn't change#11222
[Android] Call handleUpdateLayout even if the content didn't change#11222Kerumen wants to merge 1 commit into
Conversation
|
By analyzing the blame information on this pull request, we identified @astreet and @emilsjolander to be potential reviewers. |
|
Why do we need to dispatch handleUpdateLayout when the layout hasn't changed? As in, what did it break for you? I have a feeling there's a better fix we can do. |
|
I invite you to have a look at the issue I linked (#11096). I explain what worked before and broke (basically a height change that moves my button). And I created a GitHub repo with my bug. I don't doubt there is a better fix, I'm not an expert in the React Native's java source code. |
There was a problem hiding this comment.
Thanks for the repro: I just looked through the code here and this check is just not correct. It should all be handled by hasNewLayout above. As such, the correct fix is to just combine lines 301-304 into lines 289-292 and delete this entire if-block.
There was a problem hiding this comment.
Noted! I updated the PR :)
|
Awesome, thanks! |
|
@astreet has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
Thanks! This fixes something I was investigating |
Summary: This PR fixes #11096. I don't know enough the ReactAndroid's source code so I don't know if this is correct but I hope it is. In a recent commit (d4b8ae7), the `dispatchUpdates` method now returns a boolean to dispatch or not the `onLayout` event. This works well but if the content is unchanged, the line `nativeViewHierarchyOptimizer.handleUpdateLayout(this);` is never called. I don't know if it was intended but it was this which introduces my issue. I called this again even if the content didn't change. This was the behaviour before 0.38 so I guess I didn't break anything. **Test plan (required)** I tested my pretty big app with this fix and every screen is ok. Closes #11222 Differential Revision: D4252101 Pulled By: astreet fbshipit-source-id: 551559234631ac37245a854d81ba568f0ddb02dd
|
Thanks for the fix! The bug affected RN versions 0.38 and 0.39. Your fix fb23000 will be part of the 0.40 release, and was cherry picked into 0.39, and I just now cherry-picked it into 0.38 too for people who are choosing to use 0.38 over 0.39. |
Summary: This PR fixes #11096. I don't know enough the ReactAndroid's source code so I don't know if this is correct but I hope it is. In a recent commit (d4b8ae7), the `dispatchUpdates` method now returns a boolean to dispatch or not the `onLayout` event. This works well but if the content is unchanged, the line `nativeViewHierarchyOptimizer.handleUpdateLayout(this);` is never called. I don't know if it was intended but it was this which introduces my issue. I called this again even if the content didn't change. This was the behaviour before 0.38 so I guess I didn't break anything. **Test plan (required)** I tested my pretty big app with this fix and every screen is ok. Closes #11222 Differential Revision: D4252101 Pulled By: astreet fbshipit-source-id: 551559234631ac37245a854d81ba568f0ddb02dd
|
I'm having a number of issues that seem to be related to this commit. Please reference the discussion here: #11441 |
|
I am also having an issue. See here: #11809 |
That problem seems to have been on iOS, this is an Android-only change. |
|
Did you experiment with calling |
|
I'm putting up a diff internally that filters out redundant |
|
@sahrens Did that internal diff make it to production? |
|
@ramilushev Not yet but @astreet picked up the work and the diff should be in master soon. |
Summary: Developers are complaining about horrible lag (#11809) caused by PR #11222. The issue was that hasNewLayout in yoga is actually a dirty bit and indicates that either you OR one of your children has a new layout. We still need to manually check whether the component's layout actually is different from before. Reviewed By: sahrens Differential Revision: D4597545 fbshipit-source-id: 27d4605afd00badfdcdacae740ee2e477adee929
Summary: Developers are complaining about horrible lag (react#11809) caused by PR react#11222. The issue was that hasNewLayout in yoga is actually a dirty bit and indicates that either you OR one of your children has a new layout. We still need to manually check whether the component's layout actually is different from before. Reviewed By: sahrens Differential Revision: D4597545 fbshipit-source-id: 27d4605afd00badfdcdacae740ee2e477adee929
Summary: Developers are complaining about horrible lag (react#11809) caused by PR react#11222. The issue was that hasNewLayout in yoga is actually a dirty bit and indicates that either you OR one of your children has a new layout. We still need to manually check whether the component's layout actually is different from before. Reviewed By: sahrens Differential Revision: D4597545 fbshipit-source-id: 27d4605afd00badfdcdacae740ee2e477adee929
This PR fixes #11096.
I don't know enough the ReactAndroid's source code so I don't know if this is correct but I hope it is.
In a recent commit (d4b8ae7), the
dispatchUpdatesmethod now returns a boolean to dispatch or not theonLayoutevent. This works well but if the content is unchanged, the linenativeViewHierarchyOptimizer.handleUpdateLayout(this);is never called. I don't know if it was intended but it was this which introduces my issue. I called this again even if the content didn't change. This was the behaviour before 0.38 so I guess I didn't break anything.Test plan (required)
I tested my pretty big app with this fix and every screen is ok.