-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
ImGui::InputText freezes in v1.87+ in a Win32 IME ImmAssociateContextEx() call #5535
Comments
Based on the multiple reports and the fact we did make changes to Win32 IME code in 1.87, I am assuming we do have an issue but I would like to understand if it is tied to debugger loading symbols or something else.
If something appears stuck, you first want to break in the debugger to find where.
Answer is in the changelog:
Diffing between 1.86 and 1.87, the important related changes here are that we want from: static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y)
{
// Notify OS Input Method Editor of text input position
ImGuiIO& io = ImGui::GetIO();
if (HWND hwnd = (HWND)io.ImeWindowHandle)
if (HIMC himc = ::ImmGetContext(hwnd))
{
COMPOSITIONFORM cf;
cf.ptCurrentPos.x = x;
cf.ptCurrentPos.y = y;
cf.dwStyle = CFS_FORCE_POSITION;
::ImmSetCompositionWindow(himc, &cf);
::ImmReleaseContext(hwnd, himc);
}
} to static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport* viewport, ImGuiPlatformImeData* data)
{
// Notify OS Input Method Editor of text input position
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
if (hwnd == 0)
hwnd = (HWND)ImGui::GetIO().ImeWindowHandle;
#endif
if (hwnd == 0)
return;
::ImmAssociateContextEx(hwnd, NULL, data->WantVisible ? IACE_DEFAULT : 0);
if (HIMC himc = ::ImmGetContext(hwnd))
{
COMPOSITIONFORM composition_form = {};
composition_form.ptCurrentPos.x = (LONG)data->InputPos.x;
composition_form.ptCurrentPos.y = (LONG)data->InputPos.y;
composition_form.dwStyle = CFS_FORCE_POSITION;
::ImmSetCompositionWindow(himc, &composition_form);
CANDIDATEFORM candidate_form = {};
candidate_form.dwStyle = CFS_CANDIDATEPOS;
candidate_form.ptCurrentPos.x = (LONG)data->InputPos.x;
candidate_form.ptCurrentPos.y = (LONG)data->InputPos.y;
::ImmSetCandidateWindow(himc, &candidate_form);
::ImmReleaseContext(hwnd, himc);
}
} If you want to help I would need you to very precisely answer the following questions, one by one:
Thank you very much! |
Thanks for the feedback. |
@BullyWiiPlaza Do you have any third-party IMEs installed? (Or any IMEs in general?) |
No, I didn't even know what IME was exactly. Also other users had the same problem and they are often using a fairly plain Windows installation. Not sure which third-party IMEs even exist out there someone might want to install. I actually have Chinese language support installed, does that matter? I don't want to go through the process of re-testing again though unless it's needed. |
I don't know if that's the desirable logic and haven't tested it yet, but does moving the |
Yes, putting this line of code into the |
My bad this actually never re-enable the IME aftet the first time. |
@BullyWiiPlaza Could you test again but with the following version: static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport* viewport, ImGuiPlatformImeData* data)
{
// Notify OS Input Method Editor of text input position
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
if (hwnd == 0)
hwnd = (HWND)ImGui::GetIO().ImeWindowHandle;
#endif
if (hwnd == 0)
return;
::ImmAssociateContextEx(hwnd, NULL, IACE_IGNORENOCONTEXT | (data->WantVisible ? IACE_DEFAULT : 0));
if (HIMC himc = ::ImmGetContext(hwnd))
{
COMPOSITIONFORM composition_form = {};
composition_form.ptCurrentPos.x = (LONG)data->InputPos.x;
composition_form.ptCurrentPos.y = (LONG)data->InputPos.y;
composition_form.dwStyle = CFS_FORCE_POSITION;
::ImmSetCompositionWindow(himc, &composition_form);
CANDIDATEFORM candidate_form = {};
candidate_form.dwStyle = CFS_CANDIDATEPOS;
candidate_form.ptCurrentPos.x = (LONG)data->InputPos.x;
candidate_form.ptCurrentPos.y = (LONG)data->InputPos.y;
::ImmSetCandidateWindow(himc, &candidate_form);
::ImmReleaseContext(hwnd, himc);
}
} Thank you. |
@ocornut Yes, your latest code snippet also works fine, no freeze occurs. |
Thanks. But unfortunately that's not correct either, my bad :( |
@BullyWiiPlaza Could you try again with this variant instead: static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport* viewport, ImGuiPlatformImeData* data)
{
// Notify OS Input Method Editor of text input position
HWND hwnd = (HWND)viewport->PlatformHandleRaw;
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
if (hwnd == 0)
hwnd = (HWND)ImGui::GetIO().ImeWindowHandle;
#endif
if (hwnd == 0)
return;
::ImmAssociateContextEx(hwnd, NULL, (data->WantVisible ? IACE_DEFAULT : IACE_IGNORENOCONTEXT));
if (HIMC himc = ::ImmGetContext(hwnd))
{
COMPOSITIONFORM composition_form = {};
composition_form.ptCurrentPos.x = (LONG)data->InputPos.x;
composition_form.ptCurrentPos.y = (LONG)data->InputPos.y;
composition_form.dwStyle = CFS_FORCE_POSITION;
::ImmSetCompositionWindow(himc, &composition_form);
CANDIDATEFORM candidate_form = {};
candidate_form.dwStyle = CFS_CANDIDATEPOS;
candidate_form.ptCurrentPos.x = (LONG)data->InputPos.x;
candidate_form.ptCurrentPos.y = (LONG)data->InputPos.y;
::ImmSetCandidateWindow(himc, &candidate_form);
::ImmReleaseContext(hwnd, himc);
}
} Sorry for the back and forth but I still cannot repro a freeze here. |
@BullyWiiPlaza Another thing is could you confirm that your issue repro in vanilla |
This will still cause a freeze.
I compiled the vanilla example and added an |
Thanks. We’ll need to follow that trail to get to the end of this problem, if you will. You may want to fork your app and start commenting/stripping out chunks based on their likehood to interfere, aka any code dealing directly or indirectly with win32 api. |
@ocornut I could reproduce it with a pretty simple hello world example. Now I'm a bit stuck regarding what could still cause this issue. Please take a look at my repository: https://github.com/BullyWiiPlaza/ImGuiFreezingTest |
Thanks! Hmm I didn’t realize you were injecting over an existing application. This seems too complicated for me to repro so I can’t garantee I’ll look at it. Other reports of the same issue were seemingly in the same situation so i’d say they are interferences with underlying apps. |
Too complicated? ImGui development is far more complicated than this lol. Either way, take your time, it's fine. 👍 |
FWIW, I have the freezing issues on windows, not using any IME, tried all of the suggestions and they didn't work. It seems to hang for a few seconds in I've commented out the code in that function for the time being. |
It is entirely your code or are you injecting in a third party application? If the earlier that would help us constitute a full source repro.
|
I think this was fixed in 1.88 since im not getting the bug anymore but this is what i used to fix it before: If i remember correctly it got stuck in a winapi call that never returned, that's why it froze but it didn't crash. Line 12235 in 2685650
^ this is where it gets stuck on, ImmGetContext is for some reason blocking and doesn't continue execution. |
I commented that call a few commits ago while working on tracking the issue. A repro with sources would be great. |
My guess is that it's caused by non-main thread invocation of winapi, but I can't test it easily in my app. Waiting on ocornut/imgui#5535 to be fixed
Sadly, this bug still occurred today with |
Version/Branch of Dear ImGui:
Version: v1.88
Branch: https://github.com/Microsoft/vcpkg/blob/master/ports/imgui/portfile.cmake
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_win32.cpp + imgui_impl_dx11.cpp
Compiler: MSVC
Operating System: Windows 11 Pro
My Issue/Question:
I'm using
ImGui::InputText()
to create text fields. Since v.187 of Dear ImGui clicking into text fields freezes the entire application (no crash but "stopped responding"). The bug does not occur with v1.86 and the bug still occurs in v1.88.Standalone, minimal, complete and verifiable example:
I researched but didn't find a clear solution or workaround (besides downgrading to v1.86). I believe my issue is similar to #4972 and #5264. How exactly would you debug into
ImGui::InputText()
getting stuck if needed?ImGui::InputText()
takes me to theimgui_stdlib.h
file and not the.cpp
file and input texts are probably handled somewhere else. What exactly changed between those versions which could cause this regression? Thanks in advance for taking a look into this.The text was updated successfully, but these errors were encountered: