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

Improve rendering performance #644

Open
chrisvxd opened this issue Oct 7, 2024 · 6 comments
Open

Improve rendering performance #644

chrisvxd opened this issue Oct 7, 2024 · 6 comments

Comments

@chrisvxd
Copy link
Member

chrisvxd commented Oct 7, 2024

Rendering performance can sometimes be slow, with re-renders occurring whenever the app context changes in all components that depend on it.

This is particularly notable when changing field values, which makes multiple changes to the app context (due to advanced features like field resolution, data resolution, etc). This is somewhat masked by a 50ms debounce. This works, but is inconsistent and causes a delay between user input and rendered output. 50ms may also be insufficient for some environments, and shows a significant different between dev and prod environments.

We should improve rendering performance and eliminate the use of debounce entirely.

Proposals

Better memoizing

Review current memoization and improve it wherever possible.

Split contexts

Break context down into smaller chunks.

Use use-context-selector

Make use of the use-context-selector library, which implements RFC119.

Replace app context with another state solution

Various state management libraries use selectors to avoid unnecessary re-renders.

Virtualize components

Virtualize component rendering when out of view.

Considerations

@IMythx
Copy link
Contributor

IMythx commented Oct 7, 2024

i think react-tracked could help with context unwanted renders issue

@chrisvxd chrisvxd added ready Assumed ready enough to start in triage and removed ready Assumed ready enough to start labels Oct 7, 2024
@chrisvxd chrisvxd self-assigned this Oct 7, 2024
@chrisvxd
Copy link
Member Author

chrisvxd commented Oct 7, 2024

We might be able to go straight to use-context-selector

@chrisvxd chrisvxd changed the title Improve rendering performance during field changes Improve rendering performance Oct 7, 2024
@Sarfraz-droid
Copy link

Sarfraz-droid commented Oct 14, 2024

I shifted the nested context to storing objects in a global store. And rendering only the changed elements using zustand & useSyncExternalStore hook.

Could be something to consider but would require an entire state overhaul

Performance got improved by a lot. Could be something to consider

@chrisvxd
Copy link
Member Author

@Sarfraz-droid State overhaul is definitely something we could consider as part of this. Did you do that via a fork? Would be interested to see it.

@Sarfraz-droid
Copy link

I tried out those changes mostly on a private repo. By cloning puck editor to libs in a startup. But I would be happy to detach the same in a fork. Will share as soon as it's done.

@FedericoBonel
Copy link

FedericoBonel commented Oct 29, 2024

Hey @Sarfraz-droid! I kind of have the same issue you had before in: #549 (using a big data payload) would love to see how you approached this with virtualization and state overhaul.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants