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

Ticker thread might block final draw on progress bar #416

Closed
chris-laplante opened this issue Mar 22, 2022 · 0 comments · Fixed by #417
Closed

Ticker thread might block final draw on progress bar #416

chris-laplante opened this issue Mar 22, 2022 · 0 comments · Fixed by #417

Comments

@chris-laplante
Copy link
Collaborator

chris-laplante commented Mar 22, 2022

The order of events would be:

  1. You install a Ticker and it starts chugging along.
  2. main returns or panics, the ProgressBar(s) go out of scope and should be dropped.
  3. Simultaneously, let's say the Ticker is executing this line:
    state.draw(false, Instant::now()).ok();
  4. Since main returned, the thread is killed while Ticker is executing that line.
  5. The Arc is still held, so finish_using_style is never called and the spinner is not cleared.

From #407 (comment):

Please give this fork a try: https://github.com/chris-laplante/indicatif/tree/cpl/fun_with_barriers and try running: cargo run --example=long-spinner

By default I have Barrier #1 and #2 uncommented. If you comment out barrier #2 and uncomment #3, you see correct behavior (since executing proceeds after the Arc is dropped). You can also comment out all the Barriers and you should get correct behavior (unless of course, the race happens organically 😉).

@djc djc mentioned this issue Mar 23, 2022
1 task
@djc djc changed the title Ticker threads should be joined, otherwise they can race and lead to spinners that aren't properly finished Ticker thread might block final draw on progress bar Mar 23, 2022
@djc djc closed this as completed in #417 May 11, 2022
chris-laplante added a commit to chris-laplante/indicatif that referenced this issue May 26, 2022
I don't think a custom tick implementation is possible without the user
running into essentially issue console-rs#416. Coordination would be necessary
between the custom ticker and the progress bar to ensure that the custom
tick thread is joined.
chris-laplante added a commit to chris-laplante/indicatif that referenced this issue May 26, 2022
I don't think a custom tick implementation is possible without the user
running into essentially issue console-rs#416. Coordination would be necessary
between the custom ticker and the progress bar to ensure that the custom
tick thread is joined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant