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

Viewport stuck after closing when executing blocking instructions afterwards on MacOS #1593

Closed
UGLimusic opened this issue Feb 11, 2022 · 6 comments
Labels
platform: MacOS MacOS specific issue priority: low low priority type: bug bug

Comments

@UGLimusic
Copy link

OS : MacOS 12.1
Machine : MacBook Air (13-inch, Early 2015) 1,6 GHz Dual-Core Intel Core i5
Python : 3.10.1
DearPyGui : 1.3.1

import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport()
# here happens the DPG magic :)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

# Then I'd like the viewport to close and do something like
a = input() # this is what I name a "blocking instruction"
# but DPG won't close
@UGLimusic UGLimusic added state: pending not addressed yet type: bug bug labels Feb 11, 2022
@Mstpyt
Copy link
Sponsor Collaborator

Mstpyt commented Feb 11, 2022

On Windows it works with the render_loop method:

import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport()
# here happens the DPG magic :)
dpg.setup_dearpygui()
dpg.show_viewport()
while dpg.is_dearpygui_running():
    dpg.render_dearpygui_frame()
else:
    dpg.destroy_context()
    a = input("enter something:")

@hoffstadt
Copy link
Owner

Will check on this!

@hoffstadt hoffstadt added platform: MacOS MacOS specific issue priority: low low priority and removed state: pending not addressed yet labels Feb 14, 2022
@krister-ts
Copy link

viewport->running = false;

Maybe mvCleanupViewport needs to be called if running flag is cleared? I don't see anything that is testing this flag. All I could see was glfw's "should close" also clearing this flag.

I hope that helps. I may be mistaken though.

I too would like to close the viewport.

@krister-ts
Copy link

@hoffstadt This is not isolated to MacOS. I am running windows 10.

@crnbaker
Copy link
Contributor

crnbaker commented Jul 5, 2022

Related to this: on both macOS (12.2.1 on M1 Pro) and Windows (10 Enterprise 21H1 on Xeon), if you create another context and viewport immediately after destroying one, the first viewport doesn't close until the second context is destroyed (I appreciate this is possibly a bad design though!):

import dearpygui.dearpygui as dpg


def temporary_viewport(lifetime_in_frames: int) -> None:
    dpg.create_context()
    dpg.create_viewport(title="Test", width=800, height=340)

    with dpg.window(label="Test", tag="Test"):
        dpg.add_text(f"Lifetime of this viewport should be {lifetime_in_frames} frames")

    dpg.setup_dearpygui()
    dpg.show_viewport()

    frame_count = 0
    while dpg.is_dearpygui_running():
        frame_count += 1
        if frame_count > lifetime_in_frames:
            dpg.stop_dearpygui()
            dpg.destroy_context()
            break
        dpg.render_dearpygui_frame()

    print("Done")


if __name__ == "__main__":

    temporary_viewport(lifetime_in_frames=60)  # blocks for 60 frames
    # would expect first viewport to disappear here

    temporary_viewport(lifetime_in_frames=600)  # but now we end up with two viewports
    # and both of them disappear after a further 600 frames

@bandit-masked
Copy link
Collaborator

Issue for an old version of DPG. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: MacOS MacOS specific issue priority: low low priority type: bug bug
Projects
None yet
Development

No branches or pull requests

6 participants