imgui icon indicating copy to clipboard operation
imgui copied to clipboard

Delay in Combo Popup Opening with glfwWaitEventsTimeout

Open xevgeny opened this issue 1 year ago • 0 comments

Version/Branch of Dear ImGui:

master

Back-ends:

imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp

Compiler, OS:

Any

Full config/build information:

No response

Details:

I'm building a simple monitoring app using ImGUI and experimenting with resource-friendly rendering strategies. I use glfwWaitEventsTimeout with N-second granularity, which significantly reduces GPU load when there are no user inputs or events.

While I recognize that this may not be the intended use case for ImGUI, all widgets function well in this mode (Menu, TreeNode, CollapsingHeader), except the ComboBox - the popup opens with a delay when clicked.

In the attached video, the click occurs at frame 75, but the popup only appears at frame 79. Extra frames in between are rendered due to mouse input (GLFW_PRESS, GLFW_RELEASE). The thread sleeps between frames 78 and 79 due to glfwWaitEventsTimeout, which causes a noticeable delay. In the video, the timeout is set to 3 seconds.

I could not reproduce the issue with the keyboard input by selecting the ComboBox and pressing Enter.

Screenshots/Video:

Video: https://github.com/ocornut/imgui/assets/1928818/02641263-fb67-469e-9e53-75ccc0104766

Screenshot 2024-04-30 at 17 15 04

Minimal, Complete and Verifiable Example code:

To reproduce the issue replace glfwPollEvents with glfwWaitEventsTimeout in exapmle_glfw_opengl3/main.cpp file.

while (!glfwWindowShouldClose(window))
{
  // wait for an incoming event for 3 seconds
  glfwWaitEventsTimeout(3.0);
  // rendering loop continues
}

xevgeny avatar Apr 30 '24 16:04 xevgeny