-
Notifications
You must be signed in to change notification settings - Fork 24
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
Canvas2D Performance Experiments #322
base: main
Are you sure you want to change the base?
Conversation
- Canvas Text Textures are now managed properly by the texture manager - Also add willReadFrequently option to text drawing canvas element context
Do all of this one after the other when generating a text texture syncronously: Create the canvas, create the Lightning2TextTextureRenderer, caculateRenderInfo, and draw. L2 does it this way.
One concerning area of code I'm seeing is the overly complicated and dynamic
Essentially, IMHO this is incredibly inefficient: set fontSize(value: CoreTextNodeWritableProps['fontSize']) {
this.textRenderer.set.fontSize(this.trState, value);
} While something more straightforward is likely to be much faster: set fontSize(value: CoreTextNodeWritableProps['fontSize']) {
if (this.trState.props.fontSize !== value) {
this.trState.props.fontSize = value;
this.textRenderer.invalidate();
}
} |
Another consideration would be: could there be just one shared |
@elsassph This is how it's currently implemented. I was just trying this out because L2 does it that way (though it doesn't hold onto the references at all). |
The point here is to allow text renderers to decide themselves what property changes require what kind of invalidations. For instance, changing the In testing though, the property setters don't appear to be the main bottleneck to Canvas text performance. It's more in the layout and texture generation area. This code is largely pulled verbatim from L2 but it's not getting the same JIT optimizations for some reason. |
Ok it may not be the worst problem but the prop setters are a massive over-engineering and memory inefficient:
For deoptimisations, I think it's possible to run Chrome with a certain flag to log those (it might be super verbose to inspect though). |
f443716
to
3ac9adf
Compare
Experiments to squeeze more performance out of Canvas2D font rendering (in separate commits)
These changes combined don't add up to what L2 is currently producing. There is some kind of optimizations happening on the JIT side for L2 that for some reason yet to be known isn't kicking in for L3.