Skip to content
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

terminal: bump xterm and addons #12691

Merged
merged 4 commits into from
Feb 14, 2024
Merged

terminal: bump xterm and addons #12691

merged 4 commits into from
Feb 14, 2024

Conversation

vince-fugnitto
Copy link
Member

@vince-fugnitto vince-fugnitto commented Jul 10, 2023

What it does

The pull-request bumps xterm and related addons to their latest versions to benefit from additional improvements and bug fixes.

How to test

  1. start the example application(s)
  2. spawn a terminal - confirm it works as expected
  3. confirm that resizing and searching within the terminal works as expected
  4. confirm that split terminal works as expected
  5. confirm that updating terminal related preferences takes effect

Review checklist

Reminder for reviewers

@vince-fugnitto vince-fugnitto added terminal issues related to the terminal dependencies pull requests that update a dependency file labels Jul 10, 2023
@vince-fugnitto vince-fugnitto self-assigned this Jul 10, 2023
@vince-fugnitto vince-fugnitto marked this pull request as draft July 10, 2023 14:03
@vince-fugnitto vince-fugnitto marked this pull request as ready for review July 11, 2023 13:15
@msujew msujew self-requested a review July 20, 2023 14:49
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

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

The change works well on Chromium based browsers, but breaks on FireFox, since we do a bit of monkey-patching:

const renderService: any = (this.term as any)._core._renderService;
const originalFunc: (entry: IntersectionObserverEntry) => void = renderService._onIntersectionChange.bind(renderService);
const replacement = function (entry: IntersectionObserverEntry): void {
if (entry.target.ownerDocument !== document) {
// in Firefox, the intersection observer always reports the widget as non-intersecting if the dom element
// is in a different document from when the IntersectionObserver started observing. Since we know
// that the widget is always "visible" when in a secondary window, so we mark the entry as "intersecting"
const patchedEvent: IntersectionObserverEntry = {
...entry,
isIntersecting: true,
};
originalFunc(patchedEvent);
} else {
originalFunc(entry);
}
};
renderService._onIntersectionChange = replacement;

_onIntersectionChange doesn't seem to be a method in the renderService anymore.

@msujew
Copy link
Member

msujew commented Jul 20, 2023

I was able to get it to work again by replacing the existing code with this:

const renderService: any = (this.term as any)._core._renderService;
const originalFunc: (entry: IntersectionObserverEntry) => void = renderService._handleIntersectionChange.bind(renderService);
const replacement = function (entry: IntersectionObserverEntry): void {
    if (entry.target.ownerDocument !== document) {
        // in Firefox, the intersection observer always reports the widget as non-intersecting if the dom element
        // is in a different document from when the IntersectionObserver started observing. Since we know
        // that the widget is always "visible" when in a secondary window, so we refresh the rows ourselves
        renderService._pausedResizeTask.flush();
        renderService.refreshRows(0, renderService._rowCount - 1);
    } else {
        originalFunc(entry);
    }
};

renderService._handleIntersectionChange = replacement;

@vince-fugnitto
Copy link
Member Author

I was able to get it to work again by replacing the existing code with this:

@msujew good catch and thank you for the suggestion! I'll add you as a co-author whenever we merge :)

Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

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

I'll tentatively approve. There is still one edge case on FireFox that seems to experience a regression: When maximizing a secondary terminal widget, the renderer becomes quite sluggish, only updating every few seconds.

However, I couldn't figure out what causes it or how to resolve it, so I'll approve anyway. I think it's a rare enough issue. Maybe @tsmaeder can chime in and see how to fix it?

@tsmaeder
Copy link
Contributor

@msujew if I look at the relevant code change in RendererService, the method _onIntersectionChange has simply been renamed to _handleIntersectionChange. My suggestion would be to just adjust the method name, but leave the rest of the monkey-patch alone: you're proposal does refreshes unconditionally, which might well lead to the degraded performance you're observing. Was there a reason you changed more than just the method name?

@msujew
Copy link
Member

msujew commented Jul 24, 2023

Was there a reason you changed more than just the method name?

Yep, just using the correct method fixed the error in the console, but terminals still experienced a render issue. Any terminal didn't re-render anymore after popping it out to a secondary window.

@tsmaeder
Copy link
Contributor

I think this is worth investigating: if you look at the code in RendererService.ts, I think the only time the _isPaused flag is set is in the _handleIntersectionChange method, which means _needsFullRefresh is never reset to false. We're effectively turning off incremental paints, just at a glance. That doesn't sound like the right thing to do.

Copy link
Contributor

@tsmaeder tsmaeder left a comment

Choose a reason for hiding this comment

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

Putting a block on this one so nobody accidentally merges it: I believe we have a performance problem with incremental updates after the library update.

The commit bumps `xterm` and related addons to their latest versions
to benefit from additional improvements and bug fixes.

Signed-off-by: vince-fugnitto <[email protected]>
@tsmaeder
Copy link
Contributor

@msujew can you remember what the exact rendering issue was on firefox? For me, there are rendering issues when I resize the external window, but they are the same on chrome and on firefox.
@vince-fugnitto mind if I take over this one?

@vince-fugnitto
Copy link
Member Author

@vince-fugnitto mind if I take over this one?

Sure, go ahead!

- reestablished patch for intersection observer
- enabled scroll bars on Firefox

Signed-off-by: Thomas Mäder <[email protected]>
@tsmaeder tsmaeder dismissed their stale review February 14, 2024 14:30

Can't review my own changes

@tsmaeder
Copy link
Contributor

@msujew I fixed the tests. Could you give this one another review?

@tsmaeder tsmaeder requested a review from msujew February 14, 2024 14:30
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

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

Yep, perfect. Works good now. No sluggishness on Firefox anymore.

@tsmaeder tsmaeder merged commit 5bc2c2e into master Feb 14, 2024
14 checks passed
@github-actions github-actions bot added this to the 1.47.0 milestone Feb 14, 2024
@msujew msujew deleted the vf/bump-xterm branch July 8, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies pull requests that update a dependency file terminal issues related to the terminal
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants