Skip to content

Progress bar corruption during rapid terminal resize in VS Code terminal on Windows #1759

Description

@sharadvyas123

Description

While continuously resizing the VS Code integrated terminal horizontally during tqdm updates, the progress bar rendering becomes heavily corrupted.

Observed issues include:

  • duplicated progress bar lines
  • stale frames remaining visible
  • partially truncated output (for example 150/10 instead of 150/1000)
  • rendering desynchronization after repeated resize events
  • wrapped terminal rows not being properly cleared/redrawn

The corruption progressively worsens the more aggressively the terminal is resized.

The issue persists even when:

dynamic_ncols=False

which suggests the issue may not be limited to dynamic width recalculation alone, but may instead be related to wrapped terminal row cleanup/redraw behavior during resize events.


Environment

tqdm==4.67.1
Python 3.14.0
Platform: win32

Full output:

4.67.1 3.14.0 (tags/v3.14.0:ebf955d, Oct  7 2025, 10:15:03) [MSC v.1944 64 bit (AMD64)] win32

Additional environment details:

  • OS: Windows
  • Terminal: VS Code Integrated Terminal
  • Shell: PowerShell

Minimal Reproduction

import time
from tqdm import tqdm

for epoch in range(2):

    pbar = tqdm(
        range(1000),
        desc=f"Epoch {epoch}",
        dynamic_ncols=False,
    )

    for i in pbar:

        pbar.set_postfix(
            loss=f"{0.01 + (i % 10) * 0.0001:.4f}"
        )

        time.sleep(0.01)

Steps to Reproduce

  1. Run the script inside the VS Code integrated terminal on Windows.
  2. Continuously resize the terminal horizontally while tqdm is actively updating.
  3. Observe duplicated/stale progress bar output and corrupted rendering.

Expected Behavior

The progress bar should redraw cleanly after resize events without duplicated output, stale wrapped rows, or rendering desynchronization.


Actual Behavior

Rapid terminal resizing causes:

  • duplicated progress bar fragments
  • stale wrapped rows remaining on screen
  • partially overwritten/truncated output
  • progressive rendering corruption over time

The issue becomes increasingly visible during aggressive resize stress testing.


Notes

This may be related to wrapped terminal rows not being fully cleared/redrawn after resize events. Since the issue also occurs with dynamic_ncols=False, the root cause may involve carriage-return based redraw assumptions breaking once terminal wrapping changes dynamically during resize operations.

Additional observation:

The issue appears significantly worse once the rendered tqdm line wraps across multiple physical terminal rows after aggressive terminal resizing.

Image Image Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions