Use microtask to flush the write buffer after input#4159
Use microtask to flush the write buffer after input#4159Tyriar merged 2 commits intoxtermjs:masterfrom
Conversation
src/common/input/WriteBuffer.ts
Outdated
| // otherwise schedule for the next event | ||
| if (this._didUserInput) { | ||
| this._didUserInput = false; | ||
| queueMicrotask(() => this._innerWrite()); |
There was a problem hiding this comment.
If latency is your main concern here - I think we can call this._innerWrite() directly here? (after pulling the last 3 lines of the method before the call) I dont see a reason for microtask delegation here, but there is a chance I am overlooking something.
There was a problem hiding this comment.
Yes you're right, this made more sense in the previous iteration when I was relying on data length instead of the user input signal, will change
There was a problem hiding this comment.
Needed to duplicate some calls to make this happen, that's one of the reasons why it was microtask
|
@Tyriar Yepp, the direct call works nice for me. Also this PR restores scripting time back to old values, my devtools profiling is still screwed up: Note this huge greyish portion and the overall runtime. Any idea what causes this? Also note that with devtools closed I see normal runtimes. My guess would be - there is another code change, that s*cks really bad on profiler performance, but gets not really resolved by the profiler (thus shown as grey). Sadly this currently makes the devtools profiler unusable for me. |
|
I see that every now and then and it's not clear to me what it means. Does reloading the page or devtools help it go away? 🤔 |
|
Oh well found the issue - Will see if I can fix it with another PR (had to deal with it anyway in another project), for xterm.js side things seem to be fixed with this PR 👍 |
|
Ah ok, we should tweak that then. Shall we do a very similar change such that we fire the event following incoming data with queueMicrotask/immediate call? |
Yepp, should work there too 😺 |

Fixes #4158
Previously this was 5000ms+ scripting:
After input: