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

Feature request (partial rendering): Improve performance of fast scrolling #143

Closed
yaksher opened this issue Oct 20, 2023 · 3 comments · Fixed by #165
Closed

Feature request (partial rendering): Improve performance of fast scrolling #143

yaksher opened this issue Oct 20, 2023 · 3 comments · Fixed by #165

Comments

@yaksher
Copy link

yaksher commented Oct 20, 2023

When scrolling quickly through a large file with partial rendering on, the preview currently freezes and jumps back repeatedly as it tries to keep up with the scrolling.

The most basic implementations of a fix for this would be to either:

  • decouple the scrolling from the rendering (I don't know if this is possible/feasible in VS Code (you might need to spin up a whole extra process? dubiously worth it), but it would also fix the issue where you can't scroll when it's taking a long time to render)
  • just detect fast scrolling or hanging for a noticeable period of time while scrolling is trying to happen or whatever and abort the rendering until scrolling slows down

A more advanced implementation would combine the above with an augment to partial rendering with a fallback cached PDF/images, which isn't updated outside the current update scope of partial rendering but is displayed when scrolling quickly; then when scrolling slows down, overwriting it with an updated version.

The rudimentary version alone would be nice enough though.

@Enter-tainer
Copy link
Owner

we may add debounce to that, at the cost of late update. But this should be better than laggy scrolling. cc @Myriad-Dreamin how do you think of this.

@Myriad-Dreamin
Copy link
Collaborator

The debounce approach is undoubtedly a simplest solution but not quite perfect, since you don't get document content but white pages during scrolling.


But I have some thought about perfect solution. Since we have both incremental canvas and svg export, we could render document to svg inside of viewport and rest parts to canvas with low quality out of viewport.

With perfect solution, we could preview all document content during scrolling and restart svg rendering until scrollend event.

This also prepares for "typst-preview.renderMode": "canvas", which could be more lightweight but less interactable.

@yaksher
Copy link
Author

yaksher commented Oct 30, 2023

Thanks!

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

Successfully merging a pull request may close this issue.

3 participants