-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Utf8 input #1904
Utf8 input #1904
Conversation
The last commit (e6e5ecc) applies the changes to the demo. This will most likely not be part of this PR. Here are some numbers:
To make sense of those numbers: The test measures the time taken for 50MB of
😸😸 One might wonder why raw UTF8 input gives that much of a further speedup compared to string input. The reason is basically the string to charCode conversion, which happens to be way more expensive than a UTF8 to UTF32 conversion if the data is already a bunch of charCodes. For integrators this might be relevant as it will save several forth and back conversions going on from pty to xterm.js, example for our demo with websocket with string input:
With raw UTF8 this is more like (without going into details):
Lesser conversions, lesser data shuffling around in the memory. Even for remote transport UTF8 is clearly the winner, as terminal data typically contains a high percentage of ASCII chars which will save bandwidth/time. UTF8 for president. 🚀 |
Remaining for this:
|
@Tyriar |
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.
Looks good, just 2 comments then we can merge. I also did a little clean up and added an API test 🙂
Reminder to myself: Remove e6e5ecc before merging. |
I saw that too, but rebuilding fixed it 🤔 |
This PR adds UTF8 input to the terminal.
API is as simple as this:
The typed array can be picked directly from the websocket (set binaryType to 'arraybuffer') or from
node-pty
for local apps. "Binary strings" are not supported as kinda all tooling in JS world expects buffers for raw UTF8 data.To actually see this in action with the demo several changes are needed:
null
Buffer
instead of strings (see here: https://github.com/jerch/xterm.js/blob/c08c298061bd9ef3cdedf1e893535cf4b4d0555a/demo/server.js#L62-L76)binaryType
of the websocket to 'arraybuffer'.writeUtf8
instead of.write
PR relies on #1878, changes start at commit 6bdd380.
Edit:
Note that the UTF8 input currently does no flow control, thus can easily been flooded and "stall" the terminal.Fixed.