Enter-tainer / typst-preview

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

Slowness when the document has a large table of contents #240

Open psads-git opened 9 months ago

psads-git commented 9 months ago

This is just to report that preview gets notoriously slower when there is a large table of contents (generated by outline).

The reported slowness is not unacceptable, but maybe something can be done to improve the situation. Thanks!

Enter-tainer commented 9 months ago

can you show an example typ file that triggers the problem? this will help us diagnose the problem faster

psads-git commented 9 months ago

Thanks, @Enter-tainer, for your reply.

The following code shows the issue:

#set heading(level:1, numbering: "1.")

#outline()

#for i in range(1, 100) {
  let s = [Section ] + [ ] + str(i)
  heading(s)
  lorem(120)
  for j in range(1, 20) {
    let s = [Subsection] + [ ] + str(j)
    heading(level: 2, s)
    lorem(250)
  }
}
Myriad-Dreamin commented 9 months ago

The slowness is already observed in the masterproef thesis. It is caused by a typst outline element creating thousands of circles (the dots in the outline) in the page, and each circle results in many groups (<g/>) and bezier paths (<path/>). perhaps we don't have good solution. Rasterizing these dots is a way but very difficult.

Enter-tainer commented 9 months ago

to verify(and workaround) this, you may try redefine how outline is displayed -- and removing these dots. it should be faster

psads-git commented 9 months ago

Yes, @Enter-tainer, I confirm that using

#outline(fill: none)

makes it faster!