Enter-tainer / typst-preview

[DEPRECATED] Use tinymist instead
https://Enter-tainer.github.io/typst-preview/
MIT License
450 stars 21 forks source link

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

Closed yaksher closed 10 months ago

yaksher commented 10 months ago

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:

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

Thanks!