Skip to content

Android shouldn't dispatch onLayout if frame didn't change#7250

Closed
hayeah wants to merge 1 commit into
react:masterfrom
hayeah:android-onlayout-same-frame
Closed

Android shouldn't dispatch onLayout if frame didn't change#7250
hayeah wants to merge 1 commit into
react:masterfrom
hayeah:android-onlayout-same-frame

Conversation

@hayeah

@hayeah hayeah commented Apr 27, 2016

Copy link
Copy Markdown
Contributor

@ghost

ghost commented Apr 27, 2016

Copy link
Copy Markdown

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

@ghost ghost 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 Apr 27, 2016
@hayeah hayeah mentioned this pull request Apr 27, 2016
4 tasks
@hayeah

hayeah commented Apr 28, 2016

Copy link
Copy Markdown
Contributor Author

ping @mkonicek @korDen

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: space after if, split on multiple lines

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

you mean split the conditions on multiple lines?

@mkonicek

Copy link
Copy Markdown
Contributor

We should probably have a dedicated API to detect screen rotation other than:

<RootView onLayout={onDeviceRotation}>

Does this one fire if keyboard is shown for example?

@mkonicek

Copy link
Copy Markdown
Contributor

Thanks for the great description in #7202.

@mkonicek

Copy link
Copy Markdown
Contributor

I pinged some people internally to get more opinions.

@hayeah

hayeah commented Apr 29, 2016

Copy link
Copy Markdown
Contributor Author

In my own code I use onLayout in a top-level component to receive the frame. Once the container component has the frame it passes the frame down the tree hierarchy, which I use as a ersatz "percentage unit".

Something like this:

<Measure onLayout=(this.renderWithLayout)/>

In the case of keyboard event, this works exactly the same as orientation... It might be nice to have something baked-in to capture the "percentage width" concept.

@hayeah hayeah force-pushed the android-onlayout-same-frame branch from d272a41 to 61da183 Compare May 1, 2016 15:29
@ghost

ghost commented May 1, 2016

Copy link
Copy Markdown

@hayeah updated the pull request.

@hayeah

hayeah commented May 1, 2016

Copy link
Copy Markdown
Contributor Author

@mkonicek fixed nit and rebased. thanks!

@ghost

ghost commented May 31, 2016

Copy link
Copy Markdown

It's been a while since the last commit was reviewed and the labels show this pull request needs review. Based on the blame information for the files in this pull request we identified @korDen as a potential reviewer. Could you take a look please or cc someone with more context?

@thoblr

thoblr commented Jun 2, 2016

Copy link
Copy Markdown

Note that this PR is not only related to orientation but fixes a general difference how onLayout events are handled between iOS and Android. See my comment in the in issue #7202 for more info.

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 12, 2016
@itbrandonsilva

itbrandonsilva commented Aug 7, 2016

Copy link
Copy Markdown

Any updates on this?

@rigdern

rigdern commented Sep 10, 2016

Copy link
Copy Markdown
Contributor

@mkonicek any update on this PR? My team is using v0.32.0-rc.0 and we're seeing redundant onLayout events on Android as well. We're now being careful when using that event because it can fire so often as to cause performance issues.

Android's onLayout event should only fire when the view's dimensions actually change. This is the way it behaves on iOS.

Adam Comella
Microsoft Corp.

@ghost ghost added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 10, 2016
@lacker

lacker commented Oct 29, 2016

Copy link
Copy Markdown
Contributor

Hey, sorry for letting this sit for a while. The code looks pretty straightforward to me, I think @mkonicek just wanted to double-check if this is the correct behavior. Could you fix that merge conflict?

@mkonicek

Copy link
Copy Markdown
Contributor

Sorry, I got confused by #7250 mentioning device orientation. I should have read the description more carefully.

Let's ship it, I'll fix the merge conflict if there's one.

@facebook-github-bot shipit

@facebook-github-bot facebook-github-bot added GH Review: accepted Import Started This pull request has been imported. This does not imply the PR has been approved. and removed GH Review: review-needed labels Oct 31, 2016
@facebook-github-bot

Copy link
Copy Markdown
Contributor

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

@mkonicek

Copy link
Copy Markdown
Contributor

I feel bad I haven't replied on this since May! :( We have an oncall rotation for handling pull requests now, @lacker is oncall and pinged me. Thank you so much Kevin! Hopefully this new oncall rotation will improve things :)

@mkonicek

mkonicek commented Dec 5, 2016

Copy link
Copy Markdown
Contributor

@hayeah Looks like this introduced another bug and was partially reverted, see issue #11096, revert: #11222

@hayeah

hayeah commented Dec 5, 2016

Copy link
Copy Markdown
Contributor Author

looks like it's fixed in #11222

sorry about introducing the bug 😢

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. Import Started This pull request has been imported. This does not imply the PR has been approved.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants