This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Repository navigation
Implement "tiling" strategy for lines and line numbers in React editor - #2711
Closed
nathansobo wants to merge 12 commits into
Closed
nathansobo wants to merge 12 commits into
nathansobo wants to merge 12 commits into
Conversation
This is important so that styles applied to lines extend all the way across the editor. I tried to use min-width, but it was causing a full-screen repaint during scroll, which setting the width explicitly doesn't do.
Closed
Conflicts: src/highlights-component.coffee src/lines-component.coffee
Contributor
Author
|
This seemed like it might be a good idea, but it's not working out. Thanks to @benogle's keen insight, I've determined that the stutter was probably caused by using |
This file contains hidden or 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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.

🚨 Very WIP 🚨
In #2704, I attempted to make the lines the full width of the editor at all times. As soon as I did this, I started getting really bad jitter when scrolling, especially when using the discrete Nvidia graphics card on my Retina MBP.
So last night I thought I'd try a new approach. I'd tried it briefly before but now I'm coming to the situation with more knowledge and I no longer have a concern about opaque backgrounds for subpixel anti-aliasing, which didn't work anyway. I asked myself: what's the lightest possible load we can put on the graphics processor while still having it scroll our lines for us.
The issue with the approach on master is that we represent the lines as one giant layer, then paint into this layer as it is scrolling. I have no idea how it works internally so I'm working from conjecture, but it seems like having a really big layer would put more pressure on the GPU. So what if instead we break the lines and line numbers into many small layers or tiles, like the iPhone does when scrolling web pages. Then each of these layers can be controlled independently on the GPU, and we just keep creating more as they are needed when we scroll.
It's actually working better than anything I've tried so far. The tile sizes for the gutter and the lines can be tuned independently to strike a balance between having a small number of layers and not having the layers get too big. I played with the sizes a bit to find the current settings, but we could potentially tune more carefully.
This is going to require some rethinking of highlights and clever shimming for underlayer and overlayer views, but I think it's doable. And I think we need to do it, because the jitter caused by making the lines full width is really quite intolerable. As an added bonus, I think this approach lets us use React components for lines and line numbers with acceptable overhead because we can halt the updates at the level of their groupings to prevent excessive diffing. It's kinda cool that the same structure that's kind to the GPU is also kind to React. Maybe not a coincidence.