Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Tiled Line Numbers - #7101

Merged
nathansobo merged 31 commits into
masterfrom
as-tiled-gutter
Jun 30, 2015
Merged

nathansobo merged 31 commits into
masterfrom
as-tiled-gutter

Conversation

@as-cii

@as-cii as-cii commented Jun 4, 2015

Copy link
Copy Markdown
Contributor

Please, note that this is still a work in progress but it makes use of the tiling technique adopted in #6733 for line-numbers as well.

On average, with these improvements we basically halve paint times. This is a screenshot before gutter tiling:

before

And this is after:

after

To see the difference, please have a look at them at full-screen. Benchmarks were performed using the following script on text-editor-component-spec.coffee:

startBenchmark: (time=10, delta=250) ->
  @benchmarkInterval = setInterval(->
    document.querySelector("html /deep/ .editor-contents--private").dispatchEvent(new WheelEvent("mousewheel", wheelDeltaY: -delta))
  , time)

Chrome further confirms we have a ~50% speedup on paint times:

Before After
screen shot 2015-06-04 at 19 29 37 screen shot 2015-06-04 at 19 29 31

A byproduct of this change is that we'll be able to paint more than ~750k lines! 🎉

I took the chance to extract out a TiledComponent which aims to cleanly abstract away all the complexity of creating a tile on screen and moving it up and down. I think there is a similar duplication in TextEditorPresenter but I'd like to a wait a bit more before introducing an abstraction in there, too.

What's missing

  • Find a better name for TileComponent (it clashes with TiledComponent). I think we should keep the latter and get rid of the former, e.g. TileComponent -> LinesTileComponent.
  • Adjust existing specs to support this new behavior
  • Spec coverage for tiling (having a reusable contract test for this one seems like a good path, as we can use it for every TiledComponent)
  • Make sure custom gutters continue to work. @jssln: I think nothing huge should be screwed up with this PR (although changes like the one in gutter-component-helpers.coffee look suspicious), but you did a great job on the gutter and I'd ❤️ to have your feedback 🙇
  • Uncomment if @newState.maxLineNumberDigits isnt @oldState.maxLineNumberDigits and handle that scenario
  • Refine text-editor-presenter-spec.coffee's tests names

/cc: @nathansobo @maxbrunsfeld

@benogle

benogle commented Jun 4, 2015

Copy link
Copy Markdown
Contributor

🙇 🙇

@nathansobo

Copy link
Copy Markdown
Contributor

This is looking very nice. Any thoughts on how we could use composition for the TiledComponent rather than inheritance. I'm not super zealous about it but I wanted to raise the idea since I usually end up happier working with composition-oriented code rather than inheritance.

Conflicts:
	src/text-editor-presenter.coffee
@mnquintana

Copy link
Copy Markdown
Contributor

I've been using this regularly for the past day (just normal use) and it's been smooth sailing so far ⛵

Conflicts:
	src/lines-component.coffee
	src/text-editor-presenter.coffee
@nathansobo

Copy link
Copy Markdown
Contributor

Pretty excited to get this merged. What kind of support / feedback do you need to reach the 🎯?

@as-cii

as-cii commented Jun 11, 2015

Copy link
Copy Markdown
Contributor Author

Pretty excited to get this merged. What kind of support / feedback do you need to reach the ?

Yeah, I am sorry for the delays on this but I have been quite busy with the tiled editor bugs that some users reported and wanted to fix them first. I feel quite good about those now and I should be able to deliver this quite soon (this weekend I will probably have more time to actually work on it).

I understand this is quite crucial, as it allows a more expensive computation on the text measurement side without affecting UX. Hopefully, we can 🚢 this ~ by the end of this week and start making some progress on #6083 (although I suspect I am probably going to start off a new branch, as the new mechanism we'd like to try is fairly different and master has changed quite a lot).

@jssln: have you had the chance to have a look at this? Do you think this new strategy could break custom gutters? If yes, which issues do you think could arise? Any feedback is very welcome and much appreciated! ✨ 🙇

@jssln

jssln commented Jun 11, 2015

Copy link
Copy Markdown
Contributor

@as-cii Just saw this! I will take a look asap -- this is probably in a few hours, but definitely today.

Comment thread src/gutter-component-helpers.coffee Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without making changes to custom-gutter-component.coffee to account for this, custom gutter decorations will be broken by this change.

Smaller issue: can you update the comment on line 16 above?

@jssln

jssln commented Jun 11, 2015

Copy link
Copy Markdown
Contributor

by the way, here are some snippets you can use to test a custom decoration in a custom gutter (just paste in the console):

// Create a custom gutter
var e = atom.workspace.getActiveTextEditor()
var g = e.addGutter({name: 'test'})
var gv = atom.views.getView(g)
gv.style.width = '25px'

// Add a decoration
var item = document.createElement('div')
item.className = 'test-item'
item.style.width = '25px'
item.style['background-color'] = 'green'
var m = e.markBufferRange([[12, 0], [20, 0]]) // or any other buffer range
var di = e.decorateMarker(m, {type: 'gutter', gutterName: 'test', class: 'test-class', item: item})

Some things to test:

  • Create the decoration when the buffer lines it spans are off screen. Then scroll the editor until the decoration comes into view.
  • Scroll up and down and see the decoration appear/disappear as expected.
  • Test destroying the decoration and gutter
// Destroy the decoration & gutter
m.destroy() // the decoration should disappear
g.destroy() // the gutter should disappear

@as-cii

as-cii commented Jun 12, 2015

Copy link
Copy Markdown
Contributor Author

I have performed a couple of refactorings as well as completing the missing parts. This should be a drop-in replacement and no external behavior should appear as changed. I'd like to let this bake for a while but I think we're almost ready to :shipit:! 🎉

@jssln: I ended up not touching the custom gutter at all, therefore the tests you suggested work just fine and there shouldn't be any difference in there. Still, I'd be super grateful if you could have a final 👀 on this to catch eventual regressions.

@nathansobo: any feedback from your side is very welcome as usual and it'd be great to have your opinion about these changes. ✨

@mnquintana: thanks for trying this out! I feel like this is almost finished so it would be awesome if you could try it again and attempt to break it. We've caught a couple of bugs after we've released #6733 and I'd ❤️ to have a reasonable confidence before 🚢ping this (although I am quite sure this won't be as disruptive as that PR). Would you be willing to help out with that? 🙏

Thanks everyone! 🤘

Comment thread src/line-number-gutter-component.coffee Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid passing the presenter around. Are you planning to refactor this later?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, as we are already passing it in LinesComponent as well as in LinesTileComponent. I agree, though, this is an unhealthy dependency and, as far as I remember, I added it only for testing purposes (e.g. lineNodeForScreenRow and lineNumberNodeForScreenRow).

I am going to get rid of it everywhere possible and leave the responsibility of converting rows to tiles up to TextEditorComponent. I'll /cc you in the relevant upcoming commit.

Nice suggestion! 🎇

as-cii added 5 commits June 13, 2015 14:18
Although we have a couple of components which still access it, we
agreed it would have been just better to avoid relying on
`TextEditorPresenter` where possible and use it purposefully in other
places (e.g. `LinesComponent` which needs it to store text
measurements).

/cc: @jssln
@nathansobo

Copy link
Copy Markdown
Contributor

@as-cii I think the only thing holding this back is that the tiles need an opaque background for the same reasons the lines did, subpixel anti-aliasing. Good seeing you in Nashville and hope you had a good trip back!

@as-cii

as-cii commented Jun 30, 2015

Copy link
Copy Markdown
Contributor Author

I think the only thing holding this back is that the tiles need an opaque background for the same reasons the lines did, subpixel anti-aliasing.

For sure! I also introduced some assertions to ensure we don’t lose this behavior in the future. Thank you for spotting this! 🙇

nathansobo pushed a commit that referenced this pull request Jun 30, 2015
@nathansobo
nathansobo merged commit 58078e8 into master Jun 30, 2015
@nathansobo
nathansobo deleted the as-tiled-gutter branch June 30, 2015 16:54
@nathansobo

Copy link
Copy Markdown
Contributor

Thanks for finishing this out. It'll be a great relief to GPUs worldwide.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants