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

InputText display latency when trickling events #7889

Closed
kyle-sylvestre opened this issue Aug 14, 2024 · 4 comments
Closed

InputText display latency when trickling events #7889

kyle-sylvestre opened this issue Aug 14, 2024 · 4 comments

Comments

@kyle-sylvestre
Copy link

Version/Branch of Dear ImGui:

Version 1.91.1 WIP, Branch: master

Back-ends:

imgui_impl_win32.cpp + imgui_impl_dx11.cpp

Compiler, OS:

Windows 10 MSVC 2022

Full config/build information:

No response

Details:

Created from the discussion in #7886

io.ConfigInputTrickleEventQueue adds a frame delay in processing characters. This effect is cumulative, simultaneous keystrokes that would have happened in one frame are now spread over many.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

// Type fast into the input box, toggle the checkbox to see the difference
static char buf[1024];
ImGui::Begin("Trickle Latency");
ImGui::Checkbox("io.ConfigInputTrickleEventQueue", &ImGui::GetIO().ConfigInputTrickleEventQueue);
ImGui::InputText("Input", buf, sizeof(buf));
ImGui::End();
ocornut added a commit that referenced this issue Aug 19, 2024
…own to be likely to input characters. (#7889, #4921, #4858)

Amend fa2b318. Refer to regression test "inputs_io_inputqueue" amended for IMGUI_VERSION_NUM >= 19102
@ocornut
Copy link
Owner

ocornut commented Aug 19, 2024

I have pushed a fix : 092c88d (sorry forgot to amend Changelog, will be done in a subsequent commit).
It's not perfect there's a bit of heuristic involved, basically we only trickle "non-char" keys, so e.g. Key Enter + Char 'A' in same frame would be trickled, whereas Key A + Char 'A' won't.

It seems unfortunately I little bit difficult to do better without e.g. making backend provide extra information to allow us to associate key event and char event (e.g. some low-level timestamp?). I hope this workaround can get us running for a good amount of time.

If esoteric keyboard layouts requires us to reevaluate how we built KeysMayBeCharInput[] (which was built for 5fdcdf7, #456), we could potentially dynamically adjust/infer part of this based on key/event sequences.

Let me know if that works for you!

ocornut added a commit to ocornut/imgui_test_engine that referenced this issue Aug 20, 2024
@ocornut
Copy link
Owner

ocornut commented Aug 20, 2024

Amended TestSuite to take account for that:
ocornut/imgui_test_engine@9171363

@kyle-sylvestre
Copy link
Author

I'm no longer seeing the display latency in my project, thanks!

@ocornut
Copy link
Owner

ocornut commented Aug 21, 2024

Honestly I am surprised this hasn't been reported earlier, and even more so that I didn't notice it myself.
Thank you for that.

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

No branches or pull requests

2 participants