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

Experimental VirtualList Optimization #27115

Closed
wants to merge 21 commits into from

Conversation

azizhk
Copy link

@azizhk azizhk commented Nov 5, 2019

This is VirtualList Optimization done by @christianbach in #21163 enabled behind a prop: experimentalVirtualizedListOpt with backward compatibility.

Summary

Fixes #20174 based of @jasekiw pull request #20208

Changelog

// TODO:

[CATEGORY] [TYPE] - Message

Test Plan

// TODO:
Add tests related to backward compatibility. (Will need help)

@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 Nov 5, 2019
@pull-bot
Copy link

pull-bot commented Nov 5, 2019

Messages
📖

📋 Verify Changelog Format - A changelog entry has the following format: [CATEGORY] [TYPE] - Message.

CATEGORY may be:
  • General
  • iOS
  • Android
  • JavaScript
  • Internal (for changes that do not need to be called out in the release notes)

TYPE may be:

  • Added, for new features.
  • Changed, for changes in existing functionality.
  • Deprecated, for soon-to-be removed features.
  • Removed, for now removed features.
  • Fixed, for any bug fixes.
  • Security, in case of vulnerabilities.

MESSAGE may answer "what and why" on a feature level. Use this to briefly tell React Native users about notable changes.

Generated by 🚫 dangerJS against 5e9a311

@christianbach
Copy link

@cpojer this seems like a more reasonable approach. What can we do to move this along?

@cpojer cpojer changed the title Expiremental VirtualList Optimization Experemental VirtualList Optimization Nov 11, 2019
@cpojer cpojer changed the title Experemental VirtualList Optimization Experimental VirtualList Optimization Nov 11, 2019
@dominiczaq
Copy link

Is there a way to help get this merged?

@abmantis
Copy link

This is open for 9 months already. Any way to get some attention to this?

@ksitko
Copy link

ksitko commented Oct 8, 2020

Is there any reason why this has been left open?

@lunaleaps lunaleaps self-assigned this Jul 28, 2021
}
render(): React.Node {
return (
<ExperimentalVirtualizedListOptContext.Consumer>
Copy link
Contributor

@lunaleaps lunaleaps Jul 29, 2021

Choose a reason for hiding this comment

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

Some thoughts about how we do experimentation with this.

I'm hesitant about this approach because we're wrapping a Context around everyone's sticky header.
I'm thinking we approach this like the component re-factors we've been doing where we create an injection that is up to product teams to include in their bundle. The injection is read then instead of a new prop experimentalVirtualizedListOpt.

See how we're doing Animated refactor:

import createAnimatedComponentInjection from 'createAnimatedComponentInjection';
import createAnimatedComponent_EXPERIMENTAL from 'createAnimatedComponent_EXPERIMENTAL';
...

  if (<our experiment framework says you're in this test>) {
    createAnimatedComponentInjection.inject(
      createAnimatedComponent_EXPERIMENTAL,
    );
  }

So for this case we'd probably read the injection value like so:

    if (OUR_INJECTION.useExperimentalThing) {
      child.props.onLayout(event, child.props.cellKey, child.props.index);
    } else {
      child.props.onLayout(event);
    }

What do you think about this approach? I'm happy to import and make these changes

Copy link
Author

Choose a reason for hiding this comment

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

What do you think about this approach? I'm happy to import and make these changes

I didn't quite get you, but am happy to go through your PR.

@facebook-github-bot
Copy link
Contributor

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

@lunaleaps
Copy link
Contributor

@azizhk What kind of tests do you need help writing for this?

prevCellKey: prevCellKey,
onUpdateSeparators: this._onUpdateSeparators,
onUnmount: this._onCellUnmount,
extraData: extraData,
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this would be a new prop we're passing through in the "non-experiment" path. Can we update this to ensure we're not changing original behavior?

lunaleaps pushed a commit to lunaleaps/react-native that referenced this pull request Aug 4, 2021
Summary:
This is VirtualList Optimization done by christianbach in facebook#21163 enabled behind a prop: `experimentalVirtualizedListOpt` with backward compatibility.

Fixes facebook#20174 based of jasekiw pull request facebook#20208

## Changelog

// TODO:

[CATEGORY] [TYPE] - Message

Pull Request resolved: facebook#27115

Test Plan:
// TODO:
Add tests related to backward compatibility. (Will need help)

Differential Revision: D30095387

Pulled By: lunaleaps

fbshipit-source-id: 1c41e9e52beeb79b56b19dfb12d896a2c4c49529
@lunaleaps
Copy link
Contributor

@azizhk Here is what I meant by using an injection: https://github.com/facebook/react-native/pull/31947/files

Somewhere in your bundle initialization, you can enable the experiment by

import {setUseVLOptimization} from 'react-native/Libraries/Lists/VirtualizedListInjection';
...
if (yourExperimentFramework.isInExperiment) {
   setUseVLOptimization();
}

@azizhk
Copy link
Author

azizhk commented Aug 4, 2021

@azizhk What kind of tests do you need help writing for this?

Basically I need to add tests which ensure that we are not re-rendering the rows. So something like re-render the virtual list, don't expect the cells to be rendered again.

@lunaleaps
Copy link
Contributor

@azizhk's comment on https://github.com/facebook/react-native/pull/31947/files (a demonstration PR)

Ah, I see. I love this approach. 😍 Less Nesting, Less Props.
Just that now in the same tree, you can't have two versions of VirtualList one with optimization and one without. (Which I am totally fine with)

Mm that's a good point. I think since this is a question of optimizing overall that's a fine tradeoff. We'll want to run an experiment internally.. to be honest I'm not sure I understand the optimization... might have to scan the issue history a bit more closely or if you could give me TL;DR?

@github-actions
Copy link

github-actions bot commented Mar 1, 2023

This PR is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Mar 1, 2023
@github-actions
Copy link

github-actions bot commented Mar 8, 2023

This PR was closed because the author hasn't provided the requested feedback after 7 days.

@github-actions github-actions bot closed this Mar 8, 2023
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. Needs: Author Feedback Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VirtualizedList- inefficient function passing for CellRenderer
8 participants