SpaiR / imgui-java

JNI based binding for Dear ImGui
MIT License
587 stars 90 forks source link

Bug: Applications fails if you have enabled ViewportsEnable and screens with different UI scaling configured on system level #137

Open Raspberry-Crocodile opened 2 years ago

Raspberry-Crocodile commented 2 years ago

Version

1.86.4

What happened?

Applications (e.g. example from this repository - ./gradlew :example:run) with enabled ImGuiConfigFlags.ViewportsEnable fails if you have two displays with different UI scaling configured throught Windows 11 settings (e.g. 100% and 200%, 125% and 150% etc)

Reproduction

Prerequisites:
-Windows 11 Pro (21H2 v.22000.527) (have no idea is it reproducible on Windows 10 or not) -Two displays with different UI scaling (e.g. 100% and 200%, 125% and 100% etc) My monitors have different resolutions (UHD and FHD), but application runs fine while you have same (does not matter which one 100% or 175%) scaling on both monitors -Copy of this repository of version 1.86.4

Steps:

  1. execute ./gradlew :example:run

Relevant log output

[LWJGL] GLFW_PLATFORM_ERROR error
        Description : Win32: Failed to query monitor DPI
        Stacktrace  :
                org.lwjgl.glfw.GLFW.glfwGetMonitorContentScale(GLFW.java:5138)
                imgui.glfw.ImGuiImplGlfw.updateMonitors(ImGuiImplGlfw.java:587)
                imgui.glfw.ImGuiImplGlfw.init(ImGuiImplGlfw.java:324)
                imgui.app.Window.init(Window.java:50)
                imgui.app.Application.initialize(Application.java:92)
                imgui.app.Application.launch(Application.java:82)
                Main.main(Main.java:100)
Dear ImGui Assertion Failed: ImRect(mon.MainPos, mon.MainPos + mon.MainSize).Contains(ImRect(mon.WorkPos, mon.WorkPos + mon.WorkSize)) && "Monitor work bounds not setup properly. If you don't have work area information, just copy MainPos/MainSize into them."
Assertion Located At: /tmp/imgui/jni/imgui.cpp:8128
java.lang.Exception: Stack trace
        at java.lang.Thread.dumpStack(Thread.java:1341)
        at imgui.ImGui$1.imAssertCallback(ImGui.java:85)
        at imgui.assertion.ImAssertCallback.imAssert(ImAssertCallback.java:21)
        at imgui.ImGui.newFrame(Native Method)
        at imgui.app.Window.startFrame(Window.java:193)
        at imgui.app.Window.runFrame(Window.java:166)
        at imgui.app.Window.run(Window.java:158)
        at imgui.app.Application.launch(Application.java:84)
        at Main.main(Main.java:100)