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

Eliminate TextEditorComponent's reliance on MutationObserver for detecting changes in visibility, dimensions, and background color#13795

Merged
nathansobo merged 13 commits intotj-upgrade-electronfrom
ns-mb-kill-mutation-observer
Feb 18, 2017
Merged

Eliminate TextEditorComponent's reliance on MutationObserver for detecting changes in visibility, dimensions, and background color#13795
nathansobo merged 13 commits intotj-upgrade-electronfrom
ns-mb-kill-mutation-observer

Conversation

@nathansobo
Copy link
Contributor

With the introduction of Chrome 53 in Electron 1.4, we now have access to a fully functional IntersectionObserver API, which can be used to detect when editors change in visibility. This means we can discard the previous MutationObserver based polling system, which creates a drag on frame rates in certain circumstances. This impact is hard to quantify because measuring the frame rate with mutation observers in place in the current scrolling scheme seems to slow performance dramatically, making this hard to measure. Regardless it's a big simplification to not require full DOM observation.

This PR replaces polling with the following approaches:

  • Visibility detection: IntersectionObserver
  • Resize detection of editors and overlay decorations: Scroll event hack via the element-resize-detector library.
  • Transferring background to editor tiles: Plain CSS with background-color: inherit (now possible with the removal of the shadow DOM)

@nathansobo nathansobo force-pushed the ns-mb-kill-mutation-observer branch from 78b4ee9 to 27a83c6 Compare February 11, 2017 16:27
@as-cii
Copy link
Contributor

as-cii commented Feb 11, 2017

Amazing work, this looks great. ⚡️

@nathansobo
Copy link
Contributor Author

Remaining failures are related to calling atom.views.performDocumentPoll in find-and-replace and wrap-guide tests.

nathansobo pushed a commit to atom/wrap-guide that referenced this pull request Feb 14, 2017
Signed-off-by: Antonio Scandurra <as-cii@github.com>
nathansobo pushed a commit to atom/find-and-replace that referenced this pull request Feb 14, 2017
@thomasjo thomasjo force-pushed the tj-upgrade-electron branch from 8c07e68 to 91181a3 Compare February 17, 2017 11:33
@nathansobo nathansobo closed this Feb 17, 2017
@nathansobo nathansobo force-pushed the ns-mb-kill-mutation-observer branch from 84b9b7a to 91181a3 Compare February 17, 2017 17:06
Nathan Sobo added 13 commits February 17, 2017 10:19
This is an alternative to relying on pollDOM to detect when the editor
becomes visible. Our goal is to remove pollDOM in the next few commits.

Signed-off-by: Max Brunsfeld <maxbrunsfeld@github.com>
This avoids needing to poll to detect resizes.

Signed-off-by: Max Brunsfeld <maxbrunsfeld@github.com>
This is unlikely but it’s easy enough to support

Signed-off-by: Max Brunsfeld <maxbrunsfeld@github.com>
Signed-off-by: Max Brunsfeld <maxbrunsfeld@github.com>
Signed-off-by: Max Brunsfeld <maxbrunsfeld@github.com>
And don’t sample font styling in pollDOM, which we are aiming to
eliminate.

Signed-off-by: Max Brunsfeld <maxbrunsfeld@github.com>
Previously, the shadow boundary made this impossible, but the new CSS is
way simpler than the JS we’re replacing and removes another dependency
on DOM polling.
And remove pollDOM method entirely.

Signed-off-by: Max Brunsfeld <maxbrunsfeld@github.com>
Supporting it via mutation observers has a bad impact on frame rate.
@nathansobo nathansobo reopened this Feb 17, 2017
@nathansobo nathansobo merged commit 49ec99d into tj-upgrade-electron Feb 18, 2017
@nathansobo nathansobo deleted the ns-mb-kill-mutation-observer branch February 18, 2017 19:59
@nathansobo nathansobo mentioned this pull request Feb 20, 2017
17 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants