Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

fix(frontend): correct appendOffset calculation#123

Merged
Enter-tainer merged 2 commits intomainfrom
fix-svg-patch
Sep 21, 2023
Merged

fix(frontend): correct appendOffset calculation#123
Enter-tainer merged 2 commits intomainfrom
fix-svg-patch

Conversation

@Myriad-Dreamin
Copy link
Collaborator

The bug is more easily to observe with #117 not merged, because an empty main file causes single empty page to insert and then the main file recovery causes a bundle of pages to insert.

Bug Reproduce

When appending pages, the svg patches become unreliable on preserving order of elements other that <g/>. To trigger it:

#set page(height: 60pt)
#lorem(30) // append (to ensure that fresh pages appended)
#lorem(30) // append
#lorem(30) // append
#lorem(30) // append
#lorem(30) // append
#lorem(30) // append
#text(fill: red, "123") // never patch color anymore, so it is black because of bug
#text(fill: blue, "123") // never patch color anymore, so it is black because of bug

Possible behavior

Preview will have following behavior because of bug:

glyph resources desync (never happens)

What is interesting is that the first element of <svg/> is never affected, so that preview can always show all glyphs. This is because the document always has at least one page initially.

clip path resources desync (chance to #94)

The resources are stored in the second element of <svg/> will never get updated. This may heavily affect the elements to show correctly across pages, such as cross-page tables.

color resources desync (chance to #104)

The resources stored in the third element of <svg/> will never get updated. One may have change to see that new colors are not effective applied (but old colors are still available).

page out of order (not observable)

It is interesting (but not good) that, the patcher will recover the order of pages after a second patch request coming.

Testcase description

As shown in testcase handleMasterproefThesisAffectedByEmptyPage, with bug fixing, it will become:

[ "insert,1,t0" ] // before
[ "insert,4,t0" ] // after

I also construct another case handleMasterproefThesisAffectedByEmptyPageAntiCase. The patcher works occasionally since all of pages reuse corresponding <g/> elements and no DOM update happens.

@Myriad-Dreamin Myriad-Dreamin linked an issue Sep 20, 2023 that may be closed by this pull request
@Enter-tainer Enter-tainer merged commit 83274e1 into main Sep 21, 2023
@Enter-tainer Enter-tainer deleted the fix-svg-patch branch September 21, 2023 05:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fill color desync during incremental rendering

2 participants