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

SDL hangs all event processing on window move, causing ImGui to crash #57

Closed
DarkContact opened this issue Oct 30, 2019 · 7 comments
Closed

Comments

@DarkContact
Copy link

If you try to drag the window, the application will crash with an error: Expression: (g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!"

https://github.com/mosra/magnum-integration/blob/master/src/Magnum/ImGuiIntegration/Context.cpp#L252 io.DeltaTime can be zero.

Possible fix:
if (io.DeltaTime == 0.0f) { io.DeltaTime = 0.0000001f; }
but looks creepy

@mosra
Copy link
Owner

mosra commented Oct 30, 2019

Interesting. What's the platform / compiler you're on? Is it possible that the app is running at more than 60 FPS (indicating broken VSync, probably) which is causing the delta time to be very close to zero?

@mosra mosra added this to the 2019.1c milestone Oct 30, 2019
@DarkContact
Copy link
Author

Windows / MinGW 7.3.0
VSync on
image

@mosra
Copy link
Owner

mosra commented Oct 30, 2019

If you try to drag the window

Ah! Now I see -- you mean dragging the application window, not the ImGui windows, right? This could be because, IIRC, on Windows each window drag triggers a repaint for some reason, causing drawEvent() to be called much more than @ 60 FPS.

I'll need to investigate why this frequent redraw is done, if it's needed at all and how ImGui itself handles this in its own examples. Thanks for the report, I'll ping you back once I have something.

@DarkContact
Copy link
Author

Yes, I mean application window. Ok. Thanks.

@mosra
Copy link
Owner

mosra commented Feb 16, 2020

Unfortunately I don't really have a solution for this. SDL has a Window-specific bug/misfeature, reported back in 2014 and not fixed since, where it hangs all event processing for the time where you drag or resize the window. After that, it flushes the event queue, causing repaint events and everything else to happen immediately after each other. That ImGui crashes is only a consequence, it's very likely to cause serious misbehavior elsewhere as well -- I hit this most recently with mosra/magnum#423 when trying to implement DPI scaling change events, there it delays the window resize to when you release the mouse again, not nice.

I am monitoring that bug, hoping something will happen in this decade at least.

Two suggestions -- either don't drag windows with ImGui in it, or switch to GlfwApplication, GLFW doesn't suffer from this problem at all.

@mosra mosra changed the title ImGui Example runtime crash SDL hangs all event processing on window move, causing ImGui to crash Feb 16, 2020
@mosra
Copy link
Owner

mosra commented Mar 22, 2020

Worked around in e7dc17a basically the same way you suggested -- there's nothing happening about this at on the SDL side at all (the bug is milestoned for SDL 2.1, who knows when that happens), so let's do a fix here instead.

@mosra mosra closed this as completed Mar 22, 2020
@Squareys
Copy link
Contributor

Squareys commented Mar 3, 2024

libsdl-org/SDL#1059 was fixed very recently in SDL 2.30.

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

No branches or pull requests

3 participants