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

fix(core): skip updating focusPath state if unchanged #7524

Merged
merged 1 commit into from
Sep 23, 2024
Merged

Conversation

bjoerge
Copy link
Member

@bjoerge bjoerge commented Sep 19, 2024

Description

As seen in the chart below, the commit that merged #6370 had severe impact on editor FPS.

image

The reason for this is that #6370 reverted an earlier PR that, among other things, skipped updating focusPath state in DocumentPaneProvider if the emitted focusPath was (deeply) equal to the current focus path. This, in combination with the portable text input emitting onFocus on selection change, which is emitted from the portable text editor on every keystroke, triggered excessive re-renders even in cases where the focus path did not really change.

This fixes the issue by skipping the state update if focus-path hasn't changed. Instead of taking the handed focusPath as-is, it gets it from the pool of existing focus paths, which returns a stable instance for equal paths.

Relevant benchmarks.

Note: body is the Portable Text array here. Higher is better

Before

image

After (higher is better)

image

What to review

Does the change make sense?

Testing

Should be covered by existing tests.

Notes for release

  • Improved Portable Text editor performance

Copy link

vercel bot commented Sep 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 19, 2024 9:13am
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 19, 2024 9:13am
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 19, 2024 9:13am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 19, 2024 9:13am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 19, 2024 9:13am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Sep 19, 2024 9:13am

Copy link
Contributor

No changes to documentation

Copy link
Contributor

Component Testing Report Updated Sep 19, 2024 9:14 AM (UTC)

✅ All Tests Passed -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 45s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 8s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 31s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 36s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 17s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 10s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 3m 0s 0 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 45s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 45s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 15s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 8s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 26s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 18s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 36s 12 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

@bjoerge bjoerge marked this pull request as ready for review September 19, 2024 09:28
@bjoerge bjoerge requested a review from a team as a code owner September 19, 2024 09:28
@bjoerge bjoerge requested review from juice49 and removed request for a team September 19, 2024 09:28
Copy link
Contributor

@juice49 juice49 left a comment

Choose a reason for hiding this comment

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

Looks great!

@bjoerge bjoerge added this pull request to the merge queue Sep 23, 2024
Merged via the queue into next with commit 7183b24 Sep 23, 2024
42 checks passed
@bjoerge bjoerge deleted the sdx-1637 branch September 23, 2024 13:48
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