-
Notifications
You must be signed in to change notification settings - Fork 36
Ideas to improve perf on modern browsers #14
Comments
Awesome! Thanks for starting this thread |
Suggestions:
I'll edit this list to add more. 😃 |
Hi @deviousasti ,
Awesome points! Thanks! Keep up with the ideas! |
Hi @yotamberk, About #1, I've simply replaced all instances of setting the left property with transform and it works great. I modified the dist file with the above changes and it works fine.
Sections like these are abuse:
|
I think most importantly, to hit 60 fps - and it should be very feasible:
Lines like: |
This is great! The proposed changes have pretty good performance increases. There are a few issues with label stacking at the top then at the bottom if you set I've had a brief play around with getting the Looking forward to seeing this progress! |
Guys, need any help implementing this? |
PRs are always welcomed! I don;t have the time to implement this right now. |
@deviousasti, have you ever gotten to writing a pull request? otherwise i'll look into it myself :) and try to make a pull request. |
@jarnovanrhijn I wasn't able to build it before - I tested out those on the built version. |
@jarnovanrhijn I just added a few changes to @yotamberk |
@yotamberk, |
It will be sort of hacky to have it separate. Can try. |
Let me know if i can do anything to help!! |
Most likely the easiest choice would be to check if both the top and left values are present when updating the translate value. In repositionx check if this.top is already set. If not then only do translatex. If it is then do translate. The same goes to repositiony but other way around. Also another big problem in redraw performance is the forced reflows from calculating bounds, offsetheights, offsetwidths or changing inline styles to early in the dom tree nodes.. anyone checked into those? One example is the cursor change when the timeline scrolling is started. I think that style change alone causes a reflow to all children. Mostly the problems are from getting offsetwidths, offsetheights, offsetlefts and offsettops for groups and items. |
I’ve looked at some of that.
Offset calculation is the one of the biggest bottlenecks.
We might need to batch reads and writes to avoid layout thrashing.
Not sure if we need something like fastdom.
Good momentum in this thread.
Sent from Mail for Windows 10
From: Taavi Halkola
Sent: Tuesday, May 14, 2019 8:52 PM
To: yotamberk/timeline-plus
Cc: Asti; Mention
Subject: Re: [yotamberk/timeline-plus] Ideas to improve perf on modernbrowsers (#14)
Most likely the easiest choice would be to check if both the top and left values are present when updating the translate value.
In repositionx check if this.top is already set. If not then only do translatex. If it is then do translate. The same goes to repositiony but other way around.
Also another big problem in redraw performance is the forced reflows from calculating bounds, offsetheights, offsetwidths or changing inline styles to early in the dom tree nodes.. anyone checked into those? One example is the cursor change when the timeline scrolling is started. I think that style change alone causes a reflow to all children.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Made a pull request which fixes the multiple calculatings. Functions like getAbsoluteTop and getAbsoluteLeft are changed to a single util function and cached when used. Will look into the layout trashing as well!! Great to seee this alive again |
Replaced the I merged @jarnovanrhijn 's changes as well. Good find. |
tried to replace new Date() with Date.now() and tried to cache some heights and widths.. pretty sure i'm not there yet so i'll finish the rest tomorrow!! |
@deviousasti & @taavi-halkola |
@jarnovanrhijn I rewrote the positioning code for BoxItem. Please have a look. (We now have transforms!) |
The transforms alone will improve the performance allot!! Thank you for that 😄 regarding the batch read / write i think fastdom will do the trick.. although i'm not familiar with the API it shouldn't be that hard implementing it! |
I've replaced left (Core.js) with translate. this will be used when verticalScroll and maxHeight are present |
Nice!
Sent from Mail for Windows 10
From: Jarno van Rhijn
Sent: Monday, May 20, 2019 2:54 PM
To: yotamberk/timeline-plus
Cc: Asti; Mention
Subject: Re: [yotamberk/timeline-plus] Ideas to improve perf on modernbrowsers (#14)
I've replaced left (Core.js) with translate. this will be used when maxHeight is present!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I've added support for RTL transforms. Could you review the changes as i'm not 100% confident of the changes. Also, locally i've tried to use fastdom for some parts of the timeline and it indeed increases performance allot. although i think everything is too tightly coupled to do it properly. Any ideas on this topic? |
@jarnovanrhijn Nice. RangeItem has The rtl support, I'm not sure. The reason why translateX works is because it's already referenced to a left-top origin, and translate moves it relative to the absolute position of that element (which by default is 0, 0). I hope this makes it clearer. |
@deviousasti, Yeah i thought so as well. did some research and found https://rtl-css.net/tutorial/quick-tip-rtling-css3-transform-functions-translate-and-translatex which basically says make the X value a negative number. did some tests and it seems to work in some places but i can find myself in your explanation! Will revert it for now till we figure out a permanent solution! |
The alternative is to take into account the relative ‘parent’ and calculate from there, but then there’s not much perf gains to be had if you’re doing that.
That’s why I left the rtl implementation as-is.
I’ll just make everything use the repositionXY function, and we’ll figure out some better implementation later.
Sent from Mail for Windows 10
From: Jarno van Rhijn
Sent: Thursday, May 23, 2019 11:19 AM
To: yotamberk/timeline-plus
Cc: Asti; Mention
Subject: Re: [yotamberk/timeline-plus] Ideas to improve perf on modernbrowsers (#14)
@deviousasti, Yeah i thought so as well. did some research and found https://rtl-css.net/tutorial/quick-tip-rtling-css3-transform-functions-translate-and-translatex which basically says make the X value a negative number. did some tests and it seems to work in some places but i can find myself in your explanation!
Will revert it for now till we figure out a permanent solution!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@deviousasti, Thanks for all the work man!! really happy these improvements are being made! |
I had a first attempt in including fastdom in the Timeline and even though i i'm sure i did it incorrectly (hasty) i've seen major improvement in performance! this is just a test so i don't expect it to be production ready but just seeing the performance improve made me happy :D! i've created a branch in my fork which you can try and see for yourself. just run the stressPerformance.html in there and compare it with the master branch! Without fastdom my browser crashes (5000 items and 400 groups) whilst with fastdom it runs smooth as butter! |
Closed and implemented with the great work of @jarnovanrhijn with #168 |
I’m sorry for the late reply but I’m on Holiday and don’t have my laptop with me!! most of the credits go to @deviousasti though, he has made most of the improvements possible 😁👌🏻 Thanks for completing the final steps needed for this merge |
@yotamberk very excited about these changes! Any idea when an update will be available in NPM? |
This weekend \ tomorrow |
Version has been updated to v2.4.0 |
I noticed that a lot of measurement and subsequent layout recalculation is taking place in the animation frame. A lot of measured values can be cached, and perf can be improved by batching reads and writes.
For eg., the line 5563:
label.style.width = width + 'px'; // set width to prevent overflow
takes a whole 6ms (on a Ryzen 7). I'm combining this with a canvas, and its framerates end up being killed every time the timeline is moved.
Just started an issue to list ideas here.
The text was updated successfully, but these errors were encountered: