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

Spinner running faster than "steady tick" duration in v0.17 #457

Closed
sharkdp opened this issue Aug 3, 2022 · 2 comments · Fixed by #458
Closed

Spinner running faster than "steady tick" duration in v0.17 #457

sharkdp opened this issue Aug 3, 2022 · 2 comments · Fixed by #458

Comments

@sharkdp
Copy link

sharkdp commented Aug 3, 2022

When upgrading to v0.17, I noticed that the spinner may update faster than the rate set in .enable_steady_tick(…).

Background: I use .enable_steady_tick(…) to get a consistent look of my progress bar spinner animation, independent from the actual speed of .inc(…) calls (which I don't know in advance - it might be faster or slower than the rate set for the steady tick). If I update the bar at a low rate, everything is fine. But if I call .inc(…) faster than the rate set in .enable_steady_tick(…), I would still expect the spinner to update at the low refresh rate - instead of flickering arbitrarily fast in v0.17. At least this is how it worked in v0.16, and the name of the function (steady tick) seems to indicate that this is the expected outcome, even if the documentation refers to a use case where the bar is updated at a low speed.

To reproduce this, compare the output of the two programs below, with v0.16 and v0.17 as respective indicatif versions:

v0.16 version (works fine, spinner updates every 200ms)

use indicatif::{ProgressBar, ProgressStyle};
use std::thread;
use std::time::Duration;

fn main() {
    let steps = 10000;

    let progressbar_style = ProgressStyle::default_spinner()
        .template(" {spinner} {wide_bar}");

    let bar = ProgressBar::new(steps);
    bar.set_style(progressbar_style);
    bar.enable_steady_tick(200);

    for _ in 0..steps {
        bar.inc(1);
        thread::sleep(Duration::from_millis(1));
    }
}

v0.17 version (spinner updates very fast, presumably every 1ms)

use indicatif::{ProgressBar, ProgressStyle};
use std::thread;
use std::time::Duration;

fn main() {
    let steps = 10000;

    let progressbar_style = ProgressStyle::default_spinner()
        .template(" {spinner} {wide_bar}")
        .unwrap();

    let bar = ProgressBar::new(steps);
    bar.set_style(progressbar_style);
    bar.enable_steady_tick(Duration::from_millis(200));

    for _ in 0..steps {
        bar.inc(1);
        thread::sleep(Duration::from_millis(1));
    }
}
@djc
Copy link
Collaborator

djc commented Aug 3, 2022

Sorry about that, I think #458 should fix this. Would be great if you can test this!

@djc djc closed this as completed in #458 Aug 3, 2022
@sharkdp
Copy link
Author

sharkdp commented Aug 4, 2022

Thank you for the swift reply and fix! Just tested it and it works as expected!

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

Successfully merging a pull request may close this issue.

2 participants