-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Feature/xterm addon serialize restore layout and cursor #3101
Feature/xterm addon serialize restore layout and cursor #3101
Conversation
WTF, how do the same bit computation result in -0 instead of 0 in firefox? |
It looks like either xtermjs did something undefined behavior during computation (but i think js seldom do that?), or the firefox implement js incorrectly somewhere. Play with it a bit more and realize the error isn't even stable. |
@mmis1000 |
@jerch BTW, it seems there is no way to copy a IBufferCell over another. But to handle the BCE, it seems I need to keep the cursor style as background style to decide whether add ECH or not. Should I just implement a fake class based on it? |
Ah ok, yeah true. Sorry thought that is handled already. The extended attrs is still field in progress for extended style, like different underline style and colors. It is still missing the frontend bits, thus its currently not officially supported yet. Backend PR #2751, more discussion about frontend needs in #1145). Yes the private buffer cells are somewhat degenerate in their handling, they dont offer direct moving/copying around as this was not needed. They currently need the Hmm, well the private types actually form an inheritance chain for that purpose internally as |
Using an additional field for store the current background and compare against it to generate proper color sequence
This should do a complete layout restore now (include line wrap). About the performance, it handles about 5000 rows in 200ms on chrome. |
@mmis1000 Imho speed is an issue for a serializer (as it has to be blocking to obtain a correct state). We already had quite the discussion about it when reshaping the buffer API (see #2369). The fastest serializer version I was able to find for basic serialization (doing only colors and flags) is at ~25MB/s for final string output (doing 100k scrollbuffer in roughly ~1s for single unoptimized run). Much higher than that is almost impossible with JS, as pure string concatenation power of JS gets the limiting factor. See #2369 (comment), there is also a branch where you can look at the code. But note that I used very different code than the final serializer. Roughly estimated your current version should be somewhat around ~2MB/s, prolly 4MB/s for optimized runs. |
@mmis1000 Yes profiling JS is abit cumbersome, as all profilers I know do only sampling (snapshotting into callstack from time to time). Furthermore the JS engine might decide to inline hot functions, thus you would never see them being called, instead they add on top of the caller's time. The latter gets really annoying if you try to optimize hot paths, as they simply wont show up in the profiler records anymore. Hand-waving rules I found to be working with V8:
Inlining on its own is a tough topic and might be handled very different by various engines/optimizers. I only tested this with V8/crankshaft years back, but my guess is, that most ideas still apply to newer optimizers as well. For stable inlining it is important, that the arguments and the return values never change the types (e.g. if you expect a string as argument it is better to deal with an empty string instead of About string creation/concat: |
@mmis1000 Is this in a review state yet or do you need some more bits/info to be addressed? |
@jerch This is already in a review state. The part I mostly concern about is performance, but that part of code (create a array and join) is already existed in current code base. So I think it is better to left it for future pr instead of this. |
@Tyriar I am not sure whether there is some edge case that I didn't handle correctly. |
@mmis1000 busy with VS Code endgame atm, I plan on getting to this next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mmis1000, this works great. For the test change I moved it into page.evaluate
, I mainly just wanted it inside the test/ folder
Hi, sorry for bumping an old thread but, how does the cursor restoration work? I mean, it just works or do I have to enable it somehow? I don't see any difference in my use case (except for the background restoration part, which works as expected). |
Never mind, it was an issue on my side. Sorry for the noise. |
This pull request.
rows
option toscrollback
to make it work with cursor restoration.xterm-addon-serialize
that export the screen buffer state as plain object for testing.Tested on a few full screen console programs to make sure the layout is identical to original state.