-
Notifications
You must be signed in to change notification settings - Fork 118
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
WIP: dotsv2: improvements to reduce text jitteriness #353
Conversation
Contributes to gotestyourself#352 Currently, as the new screen is written the cursor jumps around the terminal. This hides it, writes everything else, then returns it. Prior art: https://github.com/docker/compose/blob/80856eacafcf96d6f27e74c07e42386fe662f8ef/pkg/progress/tty.go#L160-L162 (cherry picked from commit 77cd725)
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.
Thank you for tracking down these problems and working on the fix! I think the problems you've found definitely explain the bug.
To throttle the output, could we have dotwriter.Writer.Flush
only write every 100ms? If it is called more often we simply resetting the buffer (no print or call to clearLines
). That could potentially delay output for longer if a spike of calls to flush is followed by a long delay, but I think most of the time that wouldn't be a problem. We could handle that with a ticker that calls Flush
, which I guess would require copying the buffer instead of simply resetting it. I suspect moving the ticker and the locking to dotwriter.Writer
may simplify things a bit.
Some additional buffering using bufio
also sounds good.
Limiting line height by dropping the lines that won't be visible seems good to me. That may also be easier to do in dotwriter.Writer
, I'm not sure.
(cherry picked from commit 2a6264b)
I assume this was resolved by #368, but if not I'm happy to re-open. |
For #352
I don't think this is fully ready but its mostly usable as a POC.
Basically the jitteriness comes from two causes:
This PR fixes this by only including the last
<height>
lines (determined from inspecting the terminal) and writing updates on a 100ms timer instead of fixed.This is inspired by https://github.com/docker/compose/blob/80856eacafcf96d6f27e74c07e42386fe662f8ef/pkg/progress/tty.go#L50 which has, IMO, a pretty nice progress UI. Note they don't do the height part.
Some things I think would make this better/acceptable to merge:
Opening for early feedback