ocornut/imgui_test_engine

Race condition

elect86 opened this issue · 7 comments

In demo_misc_001 I have a breakpoint here at ctx->ItemHold("Scrolling/>>", 1.0f)

Then if I set a breakpoint at the previous line here at ctx->ItemOpen("Layout & Scrolling") the code will hit later one this LogDebug("BringWindowToDisplayFront, otherwise if there is no breakpoint, then there will be no LogDebug

Both (imgui and test) at 1.89.7

If you compare the two logs you will find the added line is:

[0071] --     BringWindowToDisplayFront('Dear ImGui Demo') (window.back=##Tooltip_00)

If you step in the debugger and wait a long time, the next frame will have a high DeltaTime and is more likely to trigger a tooltip.
I don't think that's a bug and from my POV it is preferable that running in GUI mode not in Fast-Mode follows wall-clock DeltaTime as provided by the backend.

from my POV it is preferable that running in GUI mode not in Fast-Mode follows wall-clock DeltaTime as provided by the backend.

Sorry, can you elaborate? You meant Fast-Mode is preferable than running in Gui mode?

It’s not about which is “preferable”.

If you are running in GUI mode at normal speed, io.DeltaTime every frame is the real computer time. So if you stop in a debugger you are going to get one large DeltaTima value, which could trigger a tooltip in one frame.

Could you, please, point me to the snippet triggering the tooltip with high DeltaTimes? I'd like to disable it somehow

Because this out-of-sync makes considerably more difficult to catch subtle and corner-case bugs

or, is there a way to use computing time?

point me to the snippet triggering the tooltip

Set a breakpoint in BeginTooltip() before that happens.

It's not out of sync it is in sync with the computer time.

or, is there a way to use computing time?

In ImGuiTestEngineIO:

float ConfigFixedDeltaTime = 0.0f;        // Use fixed delta time instead of calculating it from wall clock

ImGuiTestEngine_PreNewFrame() called at the beginning of NewFrame() can inject an overridden value for io.DeltaTime when ImGuiTestEngine_SetDeltaTime() is called.

When I mention out-of-sync, I mean that on the Kotlin side doesn't happen

Well it depends what your backend does with setting up io.DeltaTime.

This:
https://github.com/kotlin-graphics/imgui/blob/cd4f9365ab76f68728066435dd179a3af15658c6/bgfx/src/main/kotlin/imgui/impl/bgfx/ImplBgfx.kt#L77
Sets a fixed delta time regardless of wall clock.

Those I guess seems to use wall-clock:
https://github.com/kotlin-graphics/imgui/blob/cd4f9365ab76f68728066435dd179a3af15658c6/openjfx/src/main/kotlin/imgui/impl/ImplJFX.kt#L220
https://github.com/kotlin-graphics/imgui/blob/cd4f9365ab76f68728066435dd179a3af15658c6/glfw/src/main/kotlin/imgui/impl/glfw/ImplGlfw.kt#L251

But I have no idea how Java debuggers work and if perhaps they virtualize and stop wall-clock time when application is frozen for debugging.