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

When a form contains ArrayInput with large entries. It takes more than a minute for a form to be submitted. #9783

Open
vardhanshahpirimid opened this issue Apr 19, 2024 · 2 comments
Labels

Comments

@vardhanshahpirimid
Copy link

vardhanshahpirimid commented Apr 19, 2024

What you were expecting:
The submission of the form with ArrayInput large entries should be fast.

What happened instead:
It takes more than a minute to submit a form and the page becomes unresponsive in between.

React.Admin.-.ArrayInput.Bug.compressed.mp4

Steps to reproduce:
Sample Example v4 Try running this project locally. somehow it works fine in Stackblitz but it's getting reproduced locally as well as in our application.

Once it's running locally follow these steps to reproduce.

  1. Go to Posts resource.
  2. Edit the first entry and submit the form.

Other information:

I performed a performance profiling on this event from dev-tool. As we can see there's lot of scripting happened after submitting the form. The performance profiler results show that one function named executeBuiltInValidation from react-hook-form gets executed many times.

Profiler.results.mp4

Screenshot 2024-04-18 182600

Similarly in our application when I performed the profiling. It took a long time to submit the form as executeBuiltInValidation task takes a long time to execute.

Screenshot 2024-04-18 181514

related issue:- #8949

Environment

  • React-admin version: 4.10.6
  • React version: 17.0.0
  • Browser: Chrome
@slax57 slax57 added the bug label Apr 19, 2024
@slax57
Copy link
Contributor

slax57 commented Apr 19, 2024

Thanks for submitting this issue.

I confirm form submission is slow when there are many items in the ArrayInput, however I don't observe such drastic slowdowns.
Using the provided sandbox, performing the same action, on my computer the form submission only takes about 10 seconds.
I am running this on a 5 yo laptop.
See proof video below.

Capture.video.2024-04-19.11.22.24.mp4

Besides, I also ran a profiling using Chrome DevTools, but I see no calls to executeBuiltInValidation.

2024-04-19_11-47

I also ran a React DevTools profiling, which shows that the various TextInput components seem to be rerendered way too many times (approx. 236 rerenders at submission), which is certainly an issue.

2024-04-19_11-46

However, since the problem is, according to my tests, less critical than what your description leads to believe, and we do not have such a use-case on our projects at the moment, I can't guarantee we will fix this issue soon.

Any help diagnosing and fixing these slowdowns is welcome in the meantime.

@vardhanshahpirimid
Copy link
Author

Hello @slax57, Thank you for having a look.

Somehow, it works fine in Stackblitz for me too, there's not much lag.

The issue does not appear to be reproducible in Stackblitz. However, when the application is running locally, or when it is deployed, there is a significant lag. The same behaviour is also observed in our application.

if possible, Can you please try again running on the local machine instead of Stackblitz? The delay will be reproduced and you can observe the executeBuiltInValidation in the profiler too.

PS:- Are there any suggestions or workarounds that can be employed until the problem is resolved?

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

No branches or pull requests

2 participants