Behavior of `show_viewport()` & `is_dearpygui_running()` after closing the viewport

Open
#2,619 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp, python
Domain
desktop-dev

Research direction

Start by tracing GContext->running through mvContext::StopRendering(), is_dearpygui_running(), mvHandleMsg(), and show_viewport(). Reproduce the Windows close-and-show sequence, including split_frame() and repeated show_viewport() calls, then establish the expected running state and verify that the behavior is consistent.

Written by the indexing model from the issue text.

Description

DearPyGui v2.2
Python v3.14
Windows 11

On Windows, closing the viewport window sets GContext->running to false via mvContext::StopRendering(). is_dearpygui_running() simply returns the result of GContext->running, so it makes sense that it returns False after closing the viewport. mvHandleMsg() destroys the viewport on close (I think), but calling show_viewport() will display the viewport again. Doing so does not update GContext->running, so any code that checks against it will fail e.g. split_frame(). Everything else seems to work as it should. This can be reproduced with a debugger and some bare-bones code:

from dearpygui import dearpygui as dpg

dpg.create_context()
dpg.setup_dearpygui()
dpg.create_viewport()
dpg.show_viewport()

while True: 
    dpg.render_dearpygui_frame()

The while-loop condition does not check is_dearpygui_running() and will to run after closing the viewport. Once the viewport is closed, set a breakpoint within the render loop and call show_viewport(). This can be done repeatedly in the same thread.
(Side node: After closing the viewport at least once, calling show_viewport() while the viewport is already displayed creates a "dead" viewport window.)

This behavior isn't documented and might be limited to Windows. However, I can easily see it being useful to display the viewport again once it's been closed. In its current state, many things appear to continue functioning properly, but it may have less-obvious side-effects (I don't have enough knowledge regarding DearPyGui's internals to say for certain). This issue is mostly just to make the behavior known.

Dominant language
C++
Stars
15.7k
Forks
790
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hoffstadt/DearPyGui

All issues in hoffstadt/DearPyGui

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.