Skip to content

Conversation

@dmytrorykun
Copy link
Contributor

Summary:

Context

If a component is re-rendered/committed multiple times before mount, Android mounting layer creates and executes mounting instructions for every commit. Component's native representation is updated multiple times, potentially triggering expensive computations (e.g. recreating boxShadows) for a single draw.

A more efficient way would be to create mounting instructions to update the component from the initial state (before the first render) to the final state (after the last render) in one go.

iOS does that.

This diff is an attempt to experiment on achieving such behaviour for Android.

Implementation Details

  1. When cloning a ShadowNode, accumulate all the updates in Props.rawProps.
  2. For calculating prop update payloads to be sent to the Android mounting layer, diff old and new rawProps by calling newProps->getDiffProps(oldProps).
  3. Most importantly, move computing of the mounting instructions from schedulerDidFinishTransaction, which is called after every commit, to schedulerShouldRenderTransactions which happens only once, after the final commit.

Changelog: [Internal]

Differential Revision: D63457028

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Dec 17, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63457028

…in rawProps (facebook#48303)

Summary:

## Context

If a component is re-rendered/committed multiple times before mount, Android mounting layer creates and executes mounting instructions for every commit. Component's native representation is updated multiple times, potentially triggering expensive computations (e.g. recreating boxShadows) for a single draw.

A more efficient way would be to create mounting instructions to update the component from the initial state (before the first render) to the final state (after the last render) in one go.

iOS does that.

This diff is an attempt to experiment on achieving such behaviour for Android.

## Implementation Details

1. When cloning a ShadowNode, accumulate all the updates in `Props.rawProps`.
2. For calculating prop update payloads to be sent to the Android mounting layer, diff old and new `rawProps` by calling `newProps->getDiffProps(oldProps)`.
3. Most importantly, move computing of the mounting instructions from `schedulerDidFinishTransaction`, which is called after every commit, to `schedulerShouldRenderTransactions` which happens only once, after the final commit.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D63457028
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D63457028

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Dec 17, 2024
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 0ceb0b3.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @dmytrorykun in 0ceb0b3

When will my fix make it into a release? | How to file a pick request?

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. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants