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

[TimerMixin] Remove TimerMixin from ListView #21488

Closed
wants to merge 2 commits into from

Conversation

exced
Copy link
Contributor

@exced exced commented Oct 4, 2018

Related to #21485

  • Remove TimerMixin from ListView

Test Plan:

  • All flow tests succeed.
  • RNTester: iOS (this change should only affect iOS because calculateChildFrames is iOS only)
    Show perf monitor, show ListView* screen, start scrolling. UI frame Rate is used at the beginning. When scrolling there is no drop in FPS rate.

TODO: I think a load test would be more relevant:

  • Update props multiple times and scroll

Release Notes:

[GENERAL] [ENHANCEMENT] [ListView.js] - rm TimerMixin

@facebook-github-bot facebook-github-bot 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 Oct 4, 2018
@TheSavior
Copy link
Member

Thanks for the PR! Please note the comment about the importance of test plans from the main issue. I don't think relying on Flow for this is sufficient. We've seen some surprising errors sneak in after having made these changes when they weren't tested by running the code.

When submitting a PR removing an instance of TimerMixin, it is important to include a good test plan. This test plan helps reviewers understand the work you did to verify that your changes are correct and complete. Since this changes the runtime logic of these components, it is important that these changes are tested in an app. For most of these components, you should be able to validate your change via RNTester. If there is nothing that exists as-is in RNTester which gives you confidence in your change, adding something to RNTester would be greatly appreciated. :)

Copy link
Contributor

@RSNara RSNara left a comment

Choose a reason for hiding this comment

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

That was quick! Thanks for the PR :)

It looks mostly good, but I have a few concerns.

@@ -216,14 +215,15 @@ type Props = $ReadOnly<{|

const ListView = createReactClass({
displayName: 'ListView',
_rafId: (null: ?AnimationFrameID),
Copy link
Contributor

Choose a reason for hiding this comment

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

_rafIds: Array<AnimationFrameID>

componentDidMount: function() {
// do this in animation frame until componentDidMount actually runs after
// the component is laid out
this.requestAnimationFrame(() => {
this._rafId = requestAnimationFrame(() => {
Copy link
Contributor

@RSNara RSNara Oct 4, 2018

Choose a reason for hiding this comment

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

Both componentDidMount and componentDidUpdate will write to this._rafId, which means that the rafId from componentDidUpdate will overwrite the rafId from componentDidMount. Suppose that both hooks are executed, and then the component is unmounted, all before the first requestAnimationFrame hook is executed. Then, with the current setup, we'll end up executing this._measureAndUpdateScrollProps(); once.

To get around this, we could add the following function to ListView:

requestAnimationFrame(fn: () => void): void {
  const rafId = requestAnimationFrame(() => {
    this._rafIds.splice(this._rafIds.indexOf(rafId));
    fn();
  })
  this._rafIds.push(rafId);
},

Libraries/Lists/ListView/ListView.js Show resolved Hide resolved
Libraries/Lists/ListView/ListView.js Show resolved Hide resolved
@exced
Copy link
Contributor Author

exced commented Oct 4, 2018

You're right, I'll update it to have multiple references and come up with a test plan

@exced exced changed the title Remove TimerMixin in ListView Remove TimerMixin from ListView Oct 4, 2018
Copy link
Contributor

@RSNara RSNara left a comment

Choose a reason for hiding this comment

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

Looks good! 🧐

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

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

@hramos hramos changed the title Remove TimerMixin from ListView [TimerMixin] Remove TimerMixin from ListView Oct 5, 2018
@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Oct 5, 2018
@react-native-bot
Copy link
Collaborator

@exced merged commit 8ceb158 into facebook:master.

@facebook facebook locked as resolved and limited conversation to collaborators Oct 5, 2018
@react-native-bot react-native-bot added the Merged This PR has been merged. label Oct 5, 2018
kelset pushed a commit that referenced this pull request Oct 23, 2018
Summary:
Related to #21485

- Remove TimerMixin from ListView

- All flow tests succeed.
- RNTester: <ListView> iOS (this change should only affect iOS because calculateChildFrames is iOS only)
Show perf monitor, show ListView* screen, start scrolling. UI frame Rate is used at the beginning. When scrolling there is no drop in FPS rate.

TODO: I think a load test would be more relevant:
- Update props multiple times and scroll

[GENERAL] [ENHANCEMENT] [ListView.js] - rm TimerMixin
Pull Request resolved: #21488

Differential Revision: D10219088

Pulled By: RSNara

fbshipit-source-id: 946e4fc1319324c5bf4947a2060b18bebb6fc493
@hramos hramos removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Feb 6, 2019
t-nanava pushed a commit to microsoft/react-native-macos that referenced this pull request Jun 17, 2019
Summary:
Related to facebook#21485

- Remove TimerMixin from ListView

- All flow tests succeed.
- RNTester: <ListView> iOS (this change should only affect iOS because calculateChildFrames is iOS only)
Show perf monitor, show ListView* screen, start scrolling. UI frame Rate is used at the beginning. When scrolling there is no drop in FPS rate.

TODO: I think a load test would be more relevant:
- Update props multiple times and scroll

[GENERAL] [ENHANCEMENT] [ListView.js] - rm TimerMixin
Pull Request resolved: facebook#21488

Differential Revision: D10219088

Pulled By: RSNara

fbshipit-source-id: 946e4fc1319324c5bf4947a2060b18bebb6fc493
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants