Skip to content

[BUG] Live Progress Bars Double-Render in Jupyter Notebooks  #1737

@nicholaswold

Description

@nicholaswold

Describe the bug

Upgrading to 10.15.1 from 10.13.0 causes a double-render when using a live progress bar in a Jupyter Notebook. You can see this easily using the following example code:

from rich.progress import Progress

with Progress() as progress:
    task1 = progress.add_task("[red]Downloading...", total=2)
    while not progress.finished:
        progress.update(task1, advance=1)
        progress.refresh()

image

If it matters, we were using ipywidgets==7.6.5 for this example above. Rolling back to rich==10.13.0 fixed the issue.

You can see the section below for a description of what's happening in the Jupyter messaging protocol, but my best guess is that the ipywidgets usage is slightly off and causing this bug.

ipywidgets specifics

Normally when you update an output widget it fires the following messages:

  1. A comm_msg that specifies that all future messages apply to a specific output model
  2. A clear_output message with wait=True
  3. A display_data message including the new content
  4. A comm_msg that specifies that future messages no longer apply to a specific output model

We were noticing that this is still the case except for the final update message, in which it does the following:

  1. A comm_msg that specifies that all future messages apply to a specific output model
  2. A clear_output message with wait=True
  3. A comm_msg that specifies that future messages no longer apply to a specific output model
  4. A display_data message including the new content

The swap of those two messages caused the double-render, because the old render is never cleared by an output to that widget model, and the display_data is tracked as a new output for the cell.

Platform

Underlying platform is linux, using the classic Jupyter interface. This also happened using Noteable's interface.

╭─────────────────────── <class 'rich.console.Console'> ───────────────────────╮
│ A high level console interface.                                              │
│                                                                              │
│ ╭──────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=80 None>                                                  │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│                                                                              │
│     color_system = None                                                      │
│         encoding = 'utf-8'                                                   │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w'               │
│                    encoding='utf-8'>                                         │
│           height = 25                                                        │
│    is_alt_screen = False                                                     │
│ is_dumb_terminal = False                                                     │
│   is_interactive = False                                                     │
│       is_jupyter = False                                                     │
│      is_terminal = False                                                     │
│   legacy_windows = False                                                     │
│         no_color = False                                                     │
│          options = ConsoleOptions(                                           │
│                        size=ConsoleDimensions(width=80, height=25),          │
│                        legacy_windows=False,                                 │
│                        min_width=1,                                          │
│                        max_width=80,                                         │
│                        is_terminal=False,                                    │
│                        encoding='utf-8',                                     │
│                        max_height=25,                                        │
│                        justify=None,                                         │
│                        overflow=None,                                        │
│                        no_wrap=False,                                        │
│                        highlight=None,                                       │
│                        markup=None,                                          │
│                        height=None                                           │
│                    )                                                         │
│            quiet = False                                                     │
│           record = False                                                     │
│         safe_box = True                                                      │
│             size = ConsoleDimensions(width=80, height=25)                    │
│        soft_wrap = False                                                     │
│           stderr = False                                                     │
│            style = None                                                      │
│         tab_size = 8                                                         │
│            width = 80                                                        │
╰──────────────────────────────────────────────────────────────────────────────╯
platform="Linux"
WindowsConsoleFeatures(vt=False, truecolor=False)
rich==10.15.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions