Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Call handleUpdateLayout even if the content didn't change #11222

Closed
wants to merge 1 commit into from

Conversation

Kerumen
Copy link
Contributor

@Kerumen Kerumen commented Nov 30, 2016

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.

@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @astreet and @emilsjolander to be potential reviewers.

@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Nov 30, 2016
@astreet
Copy link
Contributor

astreet commented Nov 30, 2016

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.

@Kerumen
Copy link
Contributor Author

Kerumen commented Nov 30, 2016

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.

@@ -295,6 +295,7 @@ public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) {
newRight == mAbsoluteRight &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted! I updated the PR :)

@astreet
Copy link
Contributor

astreet commented Nov 30, 2016

Awesome, thanks!

@facebook-github-bot
Copy link
Contributor

@astreet has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@fred2028
Copy link
Contributor

fred2028 commented Dec 1, 2016

Thanks! This fixes something I was investigating

grabbou pushed a commit that referenced this pull request Dec 2, 2016
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
mkonicek referenced this pull request Dec 5, 2016
Summary:
Fixes [#7202 Android Redundant onLayout event](#7202)
Closes #7250

Differential Revision: D4104066

Pulled By: mkonicek

fbshipit-source-id: 383efdb4b4881aa7d7e508d61c9c01165bcf7bb6
@mkonicek
Copy link
Contributor

mkonicek commented Dec 5, 2016

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.

mkonicek pushed a commit that referenced this pull request Dec 5, 2016
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
robclouth pushed a commit to robclouth/react-native that referenced this pull request Dec 7, 2016
Summary:
This PR fixes facebook#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 (facebook@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 facebook#11222

Differential Revision: D4252101

Pulled By: astreet

fbshipit-source-id: 551559234631ac37245a854d81ba568f0ddb02dd
@mschipperheyn
Copy link

I'm having a number of issues that seem to be related to this commit. Please reference the discussion here: #11441

DanielMSchmidt pushed a commit to DanielMSchmidt/react-native that referenced this pull request Jan 4, 2017
Summary:
This PR fixes facebook#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 (facebook@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 facebook#11222

Differential Revision: D4252101

Pulled By: astreet

fbshipit-source-id: 551559234631ac37245a854d81ba568f0ddb02dd
@ramilushev
Copy link

ramilushev commented Jan 12, 2017

I am also having an issue. See here: #11809

@astreet
Copy link
Contributor

astreet commented Jan 24, 2017

I'm having a number of issues that seem to be related to this commit. Please reference the discussion here: #11441

That problem seems to have been on iOS, this is an Android-only change.

@sahrens
Copy link
Contributor

sahrens commented Jan 24, 2017

Did you experiment with calling nativeViewHierarchyOptimizer.handleUpdateLayout(this); just as often, but returning false if the layout coordinates didn't change? I think that could provide the onLayout optimization we want, but hopefully without breaking anything like the original diff did.

@sahrens
Copy link
Contributor

sahrens commented Jan 24, 2017

I'm putting up a diff internally that filters out redundant onLayout calls without affecting handleUpdateLayout so hopefully that will get us some solid perf wins without breaking anything :)

@ramilushev
Copy link

@sahrens Did that internal diff make it to production?

@mkonicek
Copy link
Contributor

mkonicek commented Feb 22, 2017

@ramilushev Not yet but @astreet picked up the work and the diff should be in master soon.

facebook-github-bot pushed a commit that referenced this pull request Feb 22, 2017
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
ming436534 pushed a commit to ming436534/react-native that referenced this pull request Feb 23, 2017
Summary:
Developers are complaining about horrible lag (facebook#11809) caused by PR facebook#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
GaborWnuk pushed a commit to GaborWnuk/react-native that referenced this pull request Feb 28, 2017
Summary:
Developers are complaining about horrible lag (facebook#11809) caused by PR facebook#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
dudeinthemirror pushed a commit to dudeinthemirror/react-native that referenced this pull request Mar 1, 2017
Summary:
Developers are complaining about horrible lag (facebook#11809) caused by PR facebook#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
dudeinthemirror pushed a commit to dudeinthemirror/react-native that referenced this pull request Mar 1, 2017
Summary:
Developers are complaining about horrible lag (facebook#11809) caused by PR facebook#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
lelandrichardson pushed a commit to airbnb/react-native that referenced this pull request Mar 24, 2017
Summary:
Developers are complaining about horrible lag (facebook#11809) caused by PR facebook#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
yinhangfeng pushed a commit to yinhangfeng/react-native that referenced this pull request May 11, 2017
Summary:
Developers are complaining about horrible lag (facebook#11809) caused by PR facebook#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] [0.38] Position bug when the content change
8 participants