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

Blatant flickering #1466

Closed
yenneferofvengerberg opened this issue Feb 16, 2024 · 7 comments · Fixed by #1504
Closed

Blatant flickering #1466

yenneferofvengerberg opened this issue Feb 16, 2024 · 7 comments · Fixed by #1504
Labels
bug Something isn't working needs triage

Comments

@yenneferofvengerberg
Copy link
Contributor

Information

  • OS: Windows 10/11
  • Version: 0.48.0
  • Terminal: Dos Prompt, Powershell and Windows Terminal

Describe the bug
Displaying a task list with spinners causes the whole task list to flicker. Apparently, see below, this is a regression introduced in 0.48.0

To Reproduce
The following code exhibits the issue: (tested on .net 6.0 and .net 8.0)

using Spectre.Console;

namespace TestConsole
{
    internal static class Program
    {
        private static async Task LoopAsync(ProgressTask task)
        {
            await Task.Yield();

            for (int i = 0; i < 100; i++)
            {
                task.Increment(1);
                await Task.Delay(TimeSpan.FromSeconds(4)).ConfigureAwait(false);
            }
        }

        private static async Task Main()
        {
            Console.WriteLine("Flickering Test");

            var progress = AnsiConsole.Progress()
              .AutoRefresh(true)
              .AutoClear(false)
              .HideCompleted(false)
              .Columns(
              [
                  new TaskDescriptionColumn(),
                  new ProgressBarColumn(),
                  new PercentageColumn(),
                  new RemainingTimeColumn(),
                  new SpinnerColumn(Spinner.Known.Dots),
              ]);

            await progress.StartAsync(async x =>
            {
                var tasks = new List<Task>();
                for (int i = 0; i < 10; i++)
                {
                    var t = x.AddTask($"Task {i}", true, 100);
                    tasks.Add(LoopAsync(t));
                }

                await Task.WhenAll(tasks).ConfigureAwait(false);
            }).ConfigureAwait(false);
        }
    }
}

Expected behavior
No flickering, like in 0.47.0

Screenshots
0.48.0:
Flickering
0.47.0:
NoFlickering

Additional context
The "regression" has been introduced in the commit 71a5d83

The offending line is in src/Spectre.Console/Live/LiveRenderable.cs:

-            return new ControlCode("\r" + CUU(linesToMoveUp));
+            return new ControlCode("\r" + (EL(2) + CUU(1)).Repeat(linesToMoveUp));
@ShaunLawrie
Copy link

This is also happening for other widget types in 0.48 including up to at least 0.48.1-preview.0.32 in Windows terminal

flicker.mp4

@GOATS2K
Copy link

GOATS2K commented Mar 31, 2024

This happens in progress displays without spinners as well.

@phil-scott-78
Copy link
Contributor

Can confirm what @yenneferofvengerberg posted, rolling back that commit related to long lines smooths things out again.

Probably need something a bit more clever than brute forcing a clear on each line each render. I'd almost be inclined to suggest using the RenderHook that now exists on LiveRenderables as the mechanism for including extra info while a progress is running rather than write line. Gives us a bit more control over the whole process too

@patriksvensson
Copy link
Contributor

Is there a PR to roll this back?

@yenneferofvengerberg
Copy link
Contributor Author

yenneferofvengerberg commented Apr 1, 2024 via email

@patriksvensson
Copy link
Contributor

Since it's a regression I would say that it's OK with restoring it how it was, and look at finding a solution for it later.

phil-scott-78 added a commit to phil-scott-78/spectre.console that referenced this issue Apr 1, 2024
…pt output spectreconsole#415 spectreconsole#694"

This reverts commit 71a5d83.

The commit introduced major flickering when working with LiveRenderables

Fixes spectreconsole#1466
@phil-scott-78
Copy link
Contributor

Opened a PR for the revert #1504

Regarding the original issue with WriteLine during a LiveRenderable, I wonder if some cleverness could be done to detect whether or not we can do the overwrite the content (no-flicker) vs erase what was written. Have to keep state of what was previously there on the last write, but I think it would be doable if someone had the gumption.

@github-project-automation github-project-automation bot moved this from Todo 🕑 to Done 🚀 in Spectre Console Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
Status: Done 🚀
Development

Successfully merging a pull request may close this issue.

5 participants