-
Notifications
You must be signed in to change notification settings - Fork 282
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
feat(perf): Integrate Revery layers for editor surface #2798
Open
bryphe
wants to merge
33
commits into
master
Choose a base branch
from
feat/perf/integrate-revery-layers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Today, Onivim renders like a video game - it renders the entire screen every time the state changes. Given that, it's actually amazing how performant it is, even with all this work.
Text rendering, in particular, is very expensive - and we're re-rendering all of the text, across all of the editors, every time anything changes - this is quite grossly inefficient. It also means, if one part of the UI is expensive to render, it can make every operation slower (like #1285 - a text layout inefficiency in rendering the explorer caused every. operation. to. be. slow).
revery-ui/revery#1005 adds a new primitive called a
Layer
. ALayer
actually creates it's own surface for rendering, and only updates it when a condition is met. This is exactly what we need for the editor surface and other rich UI elements to avoid the expense of text rendering when nothing has changed. It's not perfect, it only impacts draw (not layout), but it turns out the draw is significantly more costly at the moment than layout, so it addresses the largest bottleneck.The downside is that these surfaces require memory, so it's the trade-off of memory-to-runtime, but this trade-offs makes sense, as it can help facilitate a more responsive UI and avoid unnecessary rendering costs.
Another cost is the additional complexity of a re-render-condition - if this condition is not correct, there could be cases where we are not redrawing when we should (or, redrawing too aggressively). Usually, though, the condition can be simple - since these objects are immutable, a physical equality / reference check is generally sufficient.
This approach is similar to what web browsers do - except browsers do this implicitly, whereas we are adding an explicit primitive. Often developers will try and hint at the browser to promote a specific element to a layer (by using the CSS
will-change
ortransform
properties), for a smooth animation.revery-ui/revery#1005 also adds some debug visualizations to show when layers are re-rendered (green means it is not being re-rendered, red means it is) - this can help troubleshoot cases where the render condition is not correct:
TODO:
compare: functional value
)