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: preload documents on hover #8110

Merged
merged 3 commits into from
Dec 20, 2024
Merged

fix: preload documents on hover #8110

merged 3 commits into from
Dec 20, 2024

Conversation

stipsan
Copy link
Member

@stipsan stipsan commented Dec 19, 2024

Description

By preloading the editState for a document it makes for a much snappier experience when navigating documents, here's a video demonstrating both side-by-side (with the new behavior on the left, and no preloading on the right):

Screen.Recording.2024-12-19.at.14.33.33.mov

What to review

Is there enough inline context or should I add code comments?

Testing

Existing tests should capture regressions, otherwise the manual testing steps are demonstrated in the video 🙌

Notes for release

Added preloading of documents when hovering them in document list panes. This speeds up the experience of navigating between documents pretty significantly.

Copy link

vercel bot commented Dec 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 Dec 20, 2024 1:55pm
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 20, 2024 1:55pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 20, 2024 1:55pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 20, 2024 1:55pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Dec 20, 2024 1:55pm

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Dec 19, 2024

Component Testing Report Updated Dec 20, 2024 1:59 PM (UTC)

❌ Failed Tests (1) -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 1m 7s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 12s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ❌ Failed (Inspect) 1m 18s 5 0 1
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 49s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 25s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 14s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 1m 5s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 27s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 40s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 13s 3 9 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 1m 43s 21 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

@stipsan stipsan marked this pull request as ready for review December 19, 2024 13:49
@stipsan stipsan requested a review from a team as a code owner December 19, 2024 13:49
@stipsan stipsan requested review from jordanl17 and removed request for a team December 19, 2024 13:49
@stipsan stipsan enabled auto-merge December 19, 2024 13:49
Copy link
Contributor

github-actions bot commented Dec 19, 2024

⚡️ Editor Performance Report

Updated Fri, 20 Dec 2024 14:01:10 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 26.0 efps (39ms) 26.3 efps (38ms) -1ms (-1.3%)
article (body) 67.6 efps (15ms) 77.5 efps (13ms) -2ms (-/-%)
article (string inside object) 27.0 efps (37ms) 28.6 efps (35ms) -2ms (-5.4%)
article (string inside array) 25.0 efps (40ms) 26.3 efps (38ms) -2ms (-5.0%)
recipe (name) 55.6 efps (18ms) 58.8 efps (17ms) -1ms (-5.6%)
recipe (description) 62.5 efps (16ms) 66.7 efps (15ms) -1ms (-6.3%)
recipe (instructions) 99.9+ efps (5ms) 99.9+ efps (6ms) +1ms (-/-%)
synthetic (title) 18.5 efps (54ms) 18.2 efps (55ms) +1ms (+1.9%)
synthetic (string inside object) 18.9 efps (53ms) 19.6 efps (51ms) -2ms (-3.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) 39ms 45ms 55ms 387ms 266ms 10.5s
article (body) 15ms 17ms 36ms 92ms 199ms 5.5s
article (string inside object) 37ms 40ms 44ms 181ms 150ms 6.9s
article (string inside array) 40ms 42ms 47ms 150ms 131ms 6.8s
recipe (name) 18ms 22ms 24ms 40ms 0ms 6.7s
recipe (description) 16ms 17ms 19ms 37ms 0ms 4.3s
recipe (instructions) 5ms 7ms 8ms 31ms 0ms 3.0s
synthetic (title) 54ms 57ms 74ms 120ms 686ms 13.7s
synthetic (string inside object) 53ms 56ms 72ms 285ms 1032ms 8.4s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 38ms 47ms 67ms 471ms 726ms 10.0s
article (body) 13ms 15ms 37ms 192ms 214ms 5.3s
article (string inside object) 35ms 38ms 47ms 212ms 243ms 6.5s
article (string inside array) 38ms 40ms 49ms 154ms 129ms 6.6s
recipe (name) 17ms 18ms 21ms 39ms 0ms 6.6s
recipe (description) 15ms 16ms 18ms 19ms 0ms 4.2s
recipe (instructions) 6ms 7ms 8ms 96ms 0ms 3.2s
synthetic (title) 55ms 59ms 65ms 108ms 242ms 15.3s
synthetic (string inside object) 51ms 55ms 61ms 276ms 575ms 8.1s

📚 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.

@@ -124,14 +127,6 @@ export function PaneItem(props: PaneItemProps) {
documentPresence,
])

const Link = useMemo(
Copy link
Member Author

Choose a reason for hiding this comment

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

Defining components during render should be avoided whenever possible 🙌

@@ -89,7 +89,7 @@ export const Pane = forwardRef(function Pane(
ref.current = refValue
}, [])

useEffect(() => {
useLayoutEffect(() => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes a long standing quirk where clicking on a document sees a weird initial layout shift before the panel is mounted 😮‍💨

@bjoerge
Copy link
Member

bjoerge commented Dec 20, 2024

(did a rebase of this branch, fyi @stipsan)

Merged via the queue into next with commit 36dc57a Dec 20, 2024
57 checks passed
@stipsan stipsan deleted the preload-on-hover branch December 20, 2024 14:11
binoy14 pushed a commit that referenced this pull request Dec 20, 2024
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.

3 participants