Skip to content

Conversation

@miguelgrc
Copy link
Contributor

@miguelgrc miguelgrc commented Sep 26, 2025

When typing or interacting with a big form in the editor the performance became poor, making the inputs feel laggy. This was caused by many unnecessary rerenders of many different field components in reaction to formData updates. This PR implements the following changes to address this performance degradation:

  • Added 300ms debounce for formData state updates on form input changes in editor (EditablePreview).
  • Reduced unnecessary rerenders of TextWidget and SelectWidget by only subscribing to formData changes in case they have autofill or a suggestions endpoint configured, respectively, since it is not needed otherwise.
  • Added a condition to skip the persistMiddleware (which saves schemas to localStorage on change) when the action is updateFormData, removing many unnecessary saves.
  • Made the StateSychronizer not trigger when only formData has changed. This means if we want to access formData from an app we have to fetch it directly from formule (getFormuleState().formData), and not from the synced state.

These changes greatly improve the performance for big schemas. However, there is still room for improvement, as formData updates can still make the field laggy for a fraction of a second when the debounce fires.

@miguelgrc miguelgrc force-pushed the improve-input-performance branch from 24ecd62 to 36a8a1e Compare September 26, 2025 15:55
@miguelgrc miguelgrc force-pushed the improve-input-performance branch from 36a8a1e to eeb8c74 Compare October 1, 2025 12:31
<Typography.Text strong>Form data</Typography.Text>
<CodeViewer
value={JSON.stringify(formuleState?.formData, null, 2)}
value={JSON.stringify(getFormuleState().formData, null, 2)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

getFormuleState why change this, since formuleState is used around ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The SchemaSynchronizer does not update the synced state when the formData updates so now we need to get it directly from formule and not from formuleState


useEffect(() => {
synchronizeState(state);
const prev = previousStateRef.current;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's to filter out formData updates from the state sync and avoid updating the state continuously when typing

@pamfilos
Copy link
Collaborator

pamfilos commented Oct 1, 2025

also lets try fix the test

@miguelgrc miguelgrc mentioned this pull request Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants