Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.

Conversation

@nathanbennett
Copy link

Related to issue #2835. I found that having a large number of non-visible groups was causing performance issues as the items for these groups are being constantly added then removed from the DOM (so they can be restacked).

The fix I made was to only restack visible groups, and to always restack a group when it becomes visible (as it may have missed out previously). Tested these changes with Chrome DevTools and it reduces a lot of "forced reflow" hammering when dragging a timeline item.

fixcomparison

I modified an existing example to demo this (https://jsfiddle.net/nathanbennett/cbprq1vt/). This isn't a very intensive case, so you might need to use CPU throttling to see an appreciable difference :).

@Tooa Tooa added the Timeline label Mar 9, 2017
yotamberk
yotamberk approved these changes Mar 9, 2017
Copy link
Member

@yotamberk yotamberk left a comment

Choose a reason for hiding this comment

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

Awesome! I was tying to improve this issue and couldn't find an elegant way.
I will note that there is a small glitch dragging the timeline revealing a group after zooming. It is much faster but the origin bug\glitch I solved with calculating the height is kind of back (much less, but still reoccurring). Adding verticalScroll: true to the timeline options causes really bad glitches... Please try to deal with that before we can approve this PR

@Tooa Tooa added this to the Minor Release v4.20 milestone Mar 11, 2017
@nathanbennett
Copy link
Author

Thanks @yotamberk . I thought it was too simple :).

Unfortunately, there doesn't seem to be a way to prevent the vertical scroll jumping without restacking non-visible groups. I had another look at the issue, and decided the problem might not be "non-visible groups are restacking" but that "groups which haven't been changed are restacking".

All groups were being forced to restack when any item in the ItemSet changed (as this was tracked in ItemSet.stackDirty). I've had a go at changing this to be tracked at a group level, ie. Group.stackDirty, so that only the necessary groups are restacked.

The assumptions I've had to make are:

  • The parent of an item is always a Group (seems true by current code)
  • Groups only need restacking when they first appear, when an item is added/removed, when Item.setData() is called, or when the timeline is zoomed/scrolled. (I based this on the way ItemSet.stackDirty was handled)

This isn't as strong an improvement (zooming and scrolling will be as slow as before), but is still as effective for the case where an item is being dragged around.

@yotamberk
Copy link
Member

@nathanbennett Can you supply a new jsbin to show the improvements?

@nathanbennett
Copy link
Author

@yotamberk No worries. See here.

@yotamberk
Copy link
Member

Thanks! Looks good to me

@SupineSnail
Copy link

Thank you for this nathan! I merged this in locally with develop and this fixes most of my performance issues I was having with having hundreds of groups! Will be looking forward to this being merged in to the main branch.

@yotamberk
Copy link
Member

@nathanbennett can you pull from the develop branch and push again? It won;t let me merge this PR for some odd reason

* @return {boolean} Returns true if the group is resized
*/
BackgroundGroup.prototype.redraw = function(range, margin, restack) {
BackgroundGroup.prototype.redraw = function(range, margin, forceRestack) {
Copy link
Member

Choose a reason for hiding this comment

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

Why is forceRestack defined as a parameter but not used?

* @return {boolean} Returns true if the group is resized
*/
BackgroundGroup.prototype.redraw = function(range, margin, restack) {
BackgroundGroup.prototype.redraw = function(range, margin, forceRestack) {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this parameter defined but never used?

Copy link
Author

Choose a reason for hiding this comment

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

To me it looked like the idea was to keep its signature consistent with Group.prototype.redraw, so I left this as it was (other than renaming the parameter in line with my changes).

@qwe852147
Copy link

Hi, what time the new version will be released which fix redraw performance?

@yotamberk
Copy link
Member

@qwe852147 We are having trouble merging this PR. I've asked the submitter @nathanbennett to resubmit this, but yet have had a response

@yotamberk
Copy link
Member

Closed for #3078 (due to merging problems)

@yotamberk yotamberk closed this May 20, 2017
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.

7 participants