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): portable text annotations slow to show #7588

Open
wants to merge 3 commits into
base: next
Choose a base branch
from

Conversation

pedrobonamin
Copy link
Contributor

@pedrobonamin pedrobonamin commented Oct 4, 2024

Description

Adding an annotation inside the PTE editor is perceived as slow, this is mainly because the annotation needs the annotation value to exist in the form value before being able to show the Popover for it.
Also:

  • The Add comment button reappears in place of the annotation after clicking "add annotation."
  • The annotation edit/discard toolbar appears before the annotation popover renders.
  • The annotation in PTE changes its style before the annotation popover renders.
  • The popover takes about 1 second to render after clicking and doesn't focus.

Comments Input:

  • Added a blurred state to track when the editor loses focus, preventing immediate comment input display upon regaining focus (CommentsPortableTextInput.tsx).

Annotation:

  • Introduced isReady state to ensure the annotation toolbar popover is only rendered when children are present , this means that the member exists. (Annotation.tsx).

Focus in Popover Modal:

  • Implemented an effect to automatically focus the first input element when the popover modal content is rendered (PopoverModal.tsx).

Note

Upcoming changes:
The portable text editor package will be update to not debounce the addAnnotation action

Screen.Recording.2024-10-04.at.13.25.27.mov

What to review

Are this changes correct?
Is there any oversight to fix?

Testing

Visit a PTE field in the studio, add an annotation, the toolbar and comments button should not show. The first input should be focused once annotations render.
https://test-next-studio-git-pte-annotations.sanity.dev/test/structure/input-standard;portable-text;pt_allTheBellsAndWhistles;834d6ed4-7cb1-47b9-a533-a734e0f78693

Notes for release

Update annotations creations in portable text, autofocus on the first input.

Copy link

vercel bot commented Oct 4, 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 Nov 7, 2024 8:03am
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 7, 2024 8:03am
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 7, 2024 8:03am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 7, 2024 8:03am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 7, 2024 8:03am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Nov 7, 2024 8:03am

Copy link
Contributor

github-actions bot commented Oct 4, 2024

No changes to documentation

Copy link
Contributor

github-actions bot commented Oct 4, 2024

Component Testing Report Updated Nov 7, 2024 7:59 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) 32s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 39s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 18s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 10s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 2m 33s 1 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 46s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 41s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 18s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 9s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 27s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 18s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 37s 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

Copy link
Contributor

github-actions bot commented Oct 4, 2024

⚡️ Editor Performance Report

Updated Thu, 07 Nov 2024 08:02:11 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 15.9 efps (63ms) 16.7 efps (60ms) -3ms (-4.8%)
article (body) 59.9 efps (17ms) 59.5 efps (17ms) +0ms (+0.6%)
article (string inside object) 18.9 efps (53ms) 17.9 efps (56ms) +3ms (+5.7%)
article (string inside array) 16.3 efps (62ms) 15.7 efps (64ms) +2ms (+3.3%)
recipe (name) 31.3 efps (32ms) 30.3 efps (33ms) +1ms (+3.1%)
recipe (description) 34.5 efps (29ms) 34.5 efps (29ms) +0ms (-/-%)
recipe (instructions) 99.9+ efps (6ms) 99.9+ efps (6ms) +0ms (-/-%)
synthetic (title) 14.7 efps (68ms) 15.2 efps (66ms) -2ms (-2.9%)
synthetic (string inside object) 15.7 efps (64ms) 15.9 efps (63ms) -1ms (-0.8%)

efps — editor "frames per second". The number of updates assumed to be possible within a second.

Derived from input latency. efps = 1000 / input_latency

Detailed information

🏠 Reference result

The performance result of sanity@latest

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 63ms 67ms 82ms 321ms 711ms 14.5s
article (body) 17ms 19ms 32ms 75ms 170ms 5.6s
article (string inside object) 53ms 57ms 65ms 189ms 412ms 8.7s
article (string inside array) 62ms 68ms 97ms 133ms 829ms 9.4s
recipe (name) 32ms 35ms 42ms 87ms 7ms 9.7s
recipe (description) 29ms 31ms 35ms 89ms 0ms 5.9s
recipe (instructions) 6ms 8ms 9ms 34ms 0ms 3.2s
synthetic (title) 68ms 73ms 86ms 470ms 1733ms 16.1s
synthetic (string inside object) 64ms 67ms 75ms 154ms 1229ms 10.1s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 60ms 65ms 67ms 192ms 433ms 14.8s
article (body) 17ms 19ms 24ms 99ms 264ms 6.1s
article (string inside object) 56ms 60ms 87ms 225ms 539ms 8.8s
article (string inside array) 64ms 71ms 77ms 128ms 934ms 9.6s
recipe (name) 33ms 35ms 42ms 70ms 8ms 9.7s
recipe (description) 29ms 31ms 36ms 151ms 7ms 6.1s
recipe (instructions) 6ms 8ms 10ms 11ms 0ms 3.2s
synthetic (title) 66ms 70ms 82ms 336ms 1402ms 15.1s
synthetic (string inside object) 63ms 67ms 75ms 489ms 1433ms 9.6s

📚 Glossary

column definitions

  • benchmark — the name of the test, e.g. "article", followed by the label of the field being measured, e.g. "(title)".
  • latency — the time between when a key was pressed and when it was rendered. derived from a set of samples. the median (p50) is shown to show the most common latency.
  • p75 — the 75th percentile of the input latency in the test run. 75% of the sampled inputs in this benchmark were processed faster than this value. this provides insight into the upper range of typical performance.
  • p90 — the 90th percentile of the input latency in the test run. 90% of the sampled inputs were faster than this. this metric helps identify slower interactions that occurred less frequently during the benchmark.
  • p99 — the 99th percentile of the input latency in the test run. only 1% of sampled inputs were slower than this. this represents the worst-case scenarios encountered during the benchmark, useful for identifying potential performance outliers.
  • blocking time — the total time during which the main thread was blocked, preventing user input and UI updates. this metric helps identify performance bottlenecks that may cause the interface to feel unresponsive.
  • test duration — how long the test run took to complete.

Copy link
Contributor

@RitaDias RitaDias left a comment

Choose a reason for hiding this comment

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

As always, fantastic work and great pr description :)

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