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

Unfinished output during progress bar printing leads to missing output. #1948

Closed
jurgenvinju opened this issue May 21, 2024 · 5 comments · Fixed by #1951
Closed

Unfinished output during progress bar printing leads to missing output. #1948

jurgenvinju opened this issue May 21, 2024 · 5 comments · Fixed by #1951
Labels

Comments

@jurgenvinju
Copy link
Member

Describe the bug

If during the use of the progress bar monitor output is printed that does not end with a newline, then currently that output (the last line of it to be precise) is lost the moment the next version of the progress bars are printed.

Causes:

  • every progress bar currently starts with \r; however this was to mitigate the effect of the half printed lines. Without the \r the output would become very messy since the right border of the progress bar would start printing on the next line. This would lead to progressive mayhem and make everything unreadable. TL;DR; the \r was a mitigation to help make it workable until a real solution was found.
  • progress bars have to be printed from the left marging to fit, and to overwrite their own previous instantiation.
  • Unfinished lines are flushed usually, but the cursor is then not at the beginning of a line. A finished line always has the cursor at the beginning of the next, where the next progress bar can be printed.
@DavyLandman
Copy link
Member

related / duplicate of #1946 ?

@jurgenvinju
Copy link
Member Author

Yes this may very well be the cause of #1946 because:

  • In Test report is missing failed test lists #1946 the test result writer uses println a lot which first prints the line without the \n then flushes, then prints the \n. But in between the \r (see above) has already removed the line (possibly).
  • Since there is no extra buffer the line and the \n are not buffered together.

More buffering can also fix #1946 but not #1948, while fixing #1948 will also fix #1946.

@jurgenvinju
Copy link
Member Author

jurgenvinju commented May 21, 2024

An additional issue in fixing the current bug is that the progress bar outputstream is to be thread-safe. This means that there can be multiple currently unfinished lines at the same time, coming from the output of different threads. A fix for #1948 should take that into account.

@jurgenvinju
Copy link
Member Author

Done the fix in my head already; which is quite simple a (mini) buffer for the last unfinished lines of every thread.

  • the code will never print any unfinished line but instead keep it until:
    1. The endAllJobs message comes and we can print all the unfinished lines on their own line.
    2. A new output is written that contains newlines and the unfinished line for the current thread will be replaced by the new last unfinished line (if any)

@jurgenvinju
Copy link
Member Author

This way the cursor will always be at the start of the line before a progress bar is printed, or before any other output is printed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants