-
Notifications
You must be signed in to change notification settings - Fork 19
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
Jank-free rendering & shared tickers (WIP) #10
base: develop
Are you sure you want to change the base?
Conversation
Inner function should be free of memory allocation
Also mangles _step and `advancedToTime` pretty bad.
this._config.toValue = value; | ||
this._config.initialVelocity = this._currentVelocity; | ||
this.start(); | ||
this._advanceSpringToTime(undefined, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely don't like this (undefined, true)
. Perhaps it'd be best to move the raf loop into start/stop and the spring logic in step?
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script src="./index.tsx"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why you're using .tsx
here. You aren't using TypeScript or JSX, and even if you were, they'd need to be converted to JavaScript before being included in a page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dev system transpiles it to a js when running yarn dev
. I just copied from the other demo.
...this._config, | ||
...baseConfig, | ||
...updatedConfig | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why you felt the need to change this. Was there a problem, or do you just prefer the iterative style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this._config.toValue = value; | ||
this._config.initialVelocity = this._currentVelocity; | ||
this.start(); | ||
this._advanceSpringToTime(undefined, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just sugar over .updateConfig({ toValue: })
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. To avoid the object literal and extra steps updating the config when you only need to update the value (which is going to be most use cases) instead of the whole config.
Thanks for contributing! I'd like to see more context. Were there issues you were running into that led to these changes? Can we separate them out into individual pieces (e.g. Personally, I'm skeptical of changes that only have theoretical benefits or suit a personal style. If you can say "it drops frames when there are more than 4 springs running on this class of device," I'm more amenable to changes than "this is theoretically faster if you have eleventy million springs instantiated per frame." I don't mean to be a skeptic or pedant, but I would like to understand the motivation for changes before commenting on or approving them. Also, since this is a microlibrary, I'm especially conservative about API sugar. I don't see much benefit of |
I've been using my fork for a while now and have significantly less jank. My use case is with webgl drawing as many thousands of verts as I can as smoothly as I can. Every major/minor GC results in a noticeable hiccup and drop from 60fps, so this pull is about providing pathways that avoid all memory allocation so gc's don't even happen. |
Use class references to avoid unnecessary closures on draw calls
Charts are nice, so here's a couple. Here's the js heap size using wobble normally (letting it make its own
And here's the exact same demo using Half the cpu usage, half the memory usage and no GCs. 👍 |
Any thoughts? |
Any hopes of getting this PR merged? I know its been a long time 😅 |
Author doesn't really seem interested. Might as well use my fork if performance is important to you. |
That is indeed what I was considering in case there was no response! Thanks 🙂 |
I added a
setValue
function that acts as sugarfor updating config and starting. This is somewhat akin
to
setEndValue
in rebound. Name of method is totallyup for debate.
Second, I added a
raf
config option (again, name up fordebate) that stops
_step()
from registering its ownrequestAnimationFrames. With
raf: false
all springadvancing must be done manually.
That said, I mangled the living hell out of
_step
and
advanceSpringToTime
in order to get this to work.It needs some cleaning up. Perhaps
_step
becomeswhat
_advanceSpring
is now? Usually in GL landstep/tick functions are called by your main draw loop
to do whatever time-based advancing they need to do, so there'd
be some parity to existing convetions that way.
Finally, check out the squares demo I added (again it's messy).
If you watch the performance monitor heap allocation remains
constant and there's only a single raf frame 👍