-
Notifications
You must be signed in to change notification settings - Fork 83
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
RunTimeError:RuntimeError: IM_ASSERT( g.CurrentDpiScale > 0.0f && g.CurrentDpiScale < 99.0f ) #293
Comments
You may try to set
in a hello_imgui.ini as mentioned here Does that help? |
I just compile from source, and algo get this error. but I think this error should be fix at the beginning. |
I'd like to re-open this one. I only got it to work partially by first commenting the call to After uncommenting the call Removing every copy of However, instead of a |
I cannot reproduce the issue on my side, which makes it difficult to diagnose. Please provide more information about your settings:
Analysis: this assert is thrown deep inside ImGui: imgui.cpp void ImGui::SetCurrentViewport(ImGuiWindow* current_window, ImGuiViewportP* viewport)
{ ...
g.CurrentDpiScale = viewport ? viewport->DpiScale : 1.0f;
g.CurrentViewport = viewport;
IM_ASSERT(g.CurrentDpiScale > 0.0f && g.CurrentDpiScale < 99.0f); // Typical correct values would be between 1.0f and 4.0f
...
} As a consequence, According to my search, the only place where imgui.cpp ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const ImVec2& pos, const ImVec2& size, ImGuiViewportFlags flags)
{
...
// This is where ImGui uses its own platform system to set the DpiScale. Could you add some log here?
if (viewport->PlatformMonitor != -1)
viewport->DpiScale = g.PlatformIO.Monitors[viewport->PlatformMonitor].DpiScale;
...
} Things to try: demo_imgui_bundle.py: try to skip the first frames
You can reduce the size of the window using the bottom right corner, it will then be repositioned. |
My setup is Skipping the first frame was already enough to make it work. def show_module_demo(demo_filename: str, demo_function: Callable[[], None]) -> None:
if imgui.get_frame_count() < 2: # <= this alone already fixed it
return
if imgui.collapsing_header("Code for this demo"):
demo_utils.show_python_vs_cpp_file(demo_filename)
demo_function() After having been able to run the demo, I could not reproduce the odd DPI scaling issue. As for:
ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const ImVec2& pos, const ImVec2& size, ImGuiViewportFlags flags)
{
...
// This is where ImGui uses its own platform system to set the DpiScale. Could you add some log here?
if (viewport->PlatformMonitor != -1)
viewport->DpiScale = g.PlatformIO.Monitors[viewport->PlatformMonitor].DpiScale;
...
} I would gladly insert logging here, but I'm running it from VSCode using a Python 3.11.2 .venv, and I have zero C++ knowledge, so wouldn't know how to insert logging here, plus I don't think it would get executed as it will need to be recompiled?. Also, there seems to be two instances of this def. On the off chance I added this line just before the if check in both copies;
Guessing from a line slightly higher up this would be the correct syntax, but as I expected I didn't see any output in VSCode's debug console. Thinking doing |
Oddly enough, when running each of the demo's individually, there is no issue at all. |
Hum, this issue will be difficult to track. |
New wheels will be available at https://github.com/pthom/imgui_bundle/actions/runs/12398172321 |
Describe the issue
pip install imgui-bundle
demo_imgui_bundle
report error:

python version 3.10.15
The text was updated successfully, but these errors were encountered: