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

Anchor comments directly to the scroll position and optimise comment layout #10772

Merged
merged 2 commits into from
Jan 14, 2025

Conversation

Cwiiis
Copy link
Contributor

@Cwiiis Cwiiis commented Dec 19, 2024

Summary

It is desirable for comments to scroll in sync with the document instead of lagging behind the scroll position. The first commit in this branch anchors comments directly to the scroll position and the second commit fixes various performance issues doing this exposes.

Checklist

  • I have run make prettier-write and formatted the code.
  • All commits have Change-Id
  • I have run tests with make check
  • I have issued make run and manually verified that everything looks okay
  • Documentation (manuals or wiki) has been updated or is not required

@Cwiiis
Copy link
Contributor Author

Cwiiis commented Dec 19, 2024

Some failures here, likely due to the show/hide caching - I was wondering if that would hold up :) Will dig into it.

@Cwiiis
Copy link
Contributor Author

Cwiiis commented Dec 19, 2024

I'm not fully convinced these failures are directly caused by this patch - they seem to be happening because sometimes after this patch when you hit save, you end up with a conflict dialog asking if you want to overwrite changes that another user made - possibly there's some bad ordering of events and we're getting the acknowledgement back from the server before we've set a property that indicates we were the ones to have made the change... Still digging. It doesn't seem to be a cache invalidation issue at least(!)

@Cwiiis Cwiiis force-pushed the private/cwiiis/comment-perf branch from bec7104 to cf549cc Compare December 19, 2024 16:34
@Cwiiis
Copy link
Contributor Author

Cwiiis commented Dec 19, 2024

Failures should be fixed, it was caching of show/hide as I initially thought - didn't quite get to the root of it, but made sure it behaved identically to how it did before and the failures disappeared locally.

@Cwiiis
Copy link
Contributor Author

Cwiiis commented Dec 19, 2024

Ok, so still some of the same failures, I'll dig further to see if I can replicate them locally... Though the last run I had was successful, so not entirely sure what's happening now - intermittent maybe?

@Cwiiis
Copy link
Contributor Author

Cwiiis commented Dec 19, 2024

ah, just noticed it's specifically the calc annotation_spec.js that's failing - I didn't try that locally so it's probably legit again. There's specific behaviour for annotations in calc, looking at this now.

@Cwiiis
Copy link
Contributor Author

Cwiiis commented Dec 19, 2024

So I think the broken tests, it's the test themselves that are bad - they're modifying the DOM and so obviously breaking caching. I think these tests need to be rewritten to not do this, of course randomly modifying the DOM is going to break assumptions within the app... I'll try to figure out what they're trying to do and fix the tests.

@Cwiiis Cwiiis force-pushed the private/cwiiis/comment-perf branch from cf549cc to dd23fa9 Compare December 19, 2024 18:17
@Cwiiis
Copy link
Contributor Author

Cwiiis commented Dec 19, 2024

Should be good now. Rather than trying to fix all those tests and calc behaviour, I just made the choice not to cache show/hide for calc - Only one comment can be visible and they're hidden during scrolling, so it doesn't really buy us anything vs the quite large amount of work to fix this properly.

@caolanm caolanm force-pushed the private/cwiiis/comment-perf branch from dd23fa9 to 216e8f8 Compare December 19, 2024 19:31
Copy link
Contributor

@gokaysatir gokaysatir left a comment

Choose a reason for hiding this comment

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

Thanks new update mechanism feels much better:)
There are some things, not sure if they are related to your PR:

  • When i paste a long content into comment (while creating a new comment) and click on save, it doesn't save the comment and i need to click twice. This sometimes adds 2 instances of the same comment.
  • In Impress, long content of a comment has a gap above it.

If they are not related to your code, we can get this in, in RED code i think.

Other than that, i checked the code and behaviour quickly, thank you.

this.showWriter();
else if (this.sectionProperties.docLayer._docType === 'presentation' || this.sectionProperties.docLayer._docType === 'drawing')
this.hidden = false;
Copy link
Contributor

@gokaysatir gokaysatir Dec 20, 2024

Choose a reason for hiding this comment

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

I think "hidden" cannot be true if we are here. I guess we could initiate hidden as "false" and remove these assignments. Not that important but may be confusing in the future while editing the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Argh whoops, it's not this that's wrong (I don't think), but the check at the top of the function - makes me wonder how all the tests passed - I guess because they don't make multiple changes and at first the value isn't cached (intentionally, to mimic the old behaviour of the comment being in an indeterminate state on creation).

@gokaysatir gokaysatir self-requested a review December 20, 2024 09:11
Copy link
Contributor

@gokaysatir gokaysatir left a comment

Choose a reason for hiding this comment

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

Now i checked master branch. Both issues seem to be related to this PR. Can you have a look at them when you have time?

@Cwiiis
Copy link
Contributor Author

Cwiiis commented Dec 20, 2024

Now i checked master branch. Both issues seem to be related to this PR. Can you have a look at them when you have time?

Absolutely, thanks for the thorough testing 🙂

@Cwiiis Cwiiis force-pushed the private/cwiiis/comment-perf branch from 216e8f8 to 57c9cab Compare December 20, 2024 10:23
@Cwiiis Cwiiis requested a review from gokaysatir December 20, 2024 10:23
@Cwiiis
Copy link
Contributor Author

Cwiiis commented Dec 20, 2024

@gokaysatir With the mistake in CommentSection.show fixed, I can't reproduce any of the problems you list - would you mind giving it another quick check and if you still have issues, let me know very detailed steps to reproduce? Thanks :)

Copy link
Contributor

@gokaysatir gokaysatir left a comment

Choose a reason for hiding this comment

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

1

We have 2 things here:

  • I can't update a comment because of the "someone else is updating" popup.
  • There are JS errors on the console. Not sure if they were there before. Though seems unrelated to your commits, i couldn't be sure.

Can you check if you can reproduce the issues? I tried to switch to master and back to your PR to be sure. If you can't reproduce, then i'll need to refresh browser cache and dist directory.

Gap in Impress comments seems to persist, but i couldn't check correctly because of the popup.

Chris Lord added 2 commits January 13, 2025 10:03
Don't postpone and don't animate comment block position changes when
scrolling or resizing the document.

Signed-off-by: Chris Lord <[email protected]>
Change-Id: I95c1ae1eb732c6dc682018b85debb6133d85ce8c
CommentListSection layout appears very high in the profile when scrolling.
This commit makes various optimisations, mainly around doing less
unnecessary work while scrolling and caching regularly accessed values.
Comment layout no longer appears anywhere significant in the profile in
Writer after this patch.

Signed-off-by: Chris Lord <[email protected]>
Change-Id: I3bc8d040422703375b583fbc8c49bd793547514d
@Cwiiis Cwiiis force-pushed the private/cwiiis/comment-perf branch from 57c9cab to ac480b5 Compare January 13, 2025 11:16
@Cwiiis
Copy link
Contributor Author

Cwiiis commented Jan 13, 2025

Hopefully I've fixed these issues - the problem was the interaction with editing and show/hide caching. In the end it made sense to also fix isEdit being slow by caching that value. Annotation tests now pass locally.

I think long-term, we need to have a bit of an audit of the codebase - there's too much direct DOM modification and reading peppered through the code and we'd likely fix a lot of performance issues by consolidating all DOM access into a few context-specific utility functions that could also cache the last state that was set. For example, in the CommentSection case specifically, nodeModify and nodeReply are frequently accessed and modified directly, but we could consolidate these into just a couple of functions, e.g. setModifyVisible, setReplyVisible and corresponding properties to access that state. This would improve performance and make the code more concise and readable.

@Cwiiis
Copy link
Contributor Author

Cwiiis commented Jan 13, 2025

Seems I can't win with this patch! I can reproduce the invalidations failure locally, investigating now...

Edit: Actually, this is an unrelated intermittent failure.

@gokaysatir gokaysatir self-requested a review January 13, 2025 15:09
Copy link
Contributor

@gokaysatir gokaysatir left a comment

Choose a reason for hiding this comment

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

Thanks for the improvements :) I reviewed this before. And now issues are gone. I think we can get this in.

@gokaysatir gokaysatir merged commit d255c10 into master Jan 14, 2025
14 checks passed
@gokaysatir gokaysatir deleted the private/cwiiis/comment-perf branch January 14, 2025 14:28
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 this pull request may close these issues.

CommentSection layout is very expensive while scrolling
2 participants