imgui: Crash with Metal/SDL when switching to fullscreen

Dear ImGui 1.84 WIP (18313)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201402
define: __APPLE__
define: __GNUC__=4
define: __clang_version__=12.0.5 (clang-1205.0.22.11)
--------------------------------
io.BackendPlatformName: imgui_impl_sdl
io.BackendRendererName: imgui_impl_metal
io.ConfigFlags: 0x00000003
 NavEnableKeyboard
 NavEnableGamepad
io.ConfigMacOSXBehaviors
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x0000000E
 HasMouseCursors
 HasSetMousePos
 RendererHasVtxOffset
--------------------------------
io.Fonts: 2 fonts, Flags: 0x00000000, TexSize: 512,256
io.DisplaySize: 1280.00,720.00
io.DisplayFramebufferScale: 2.00,2.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Version/Branch of Dear ImGui:

Version: #f99fe72 Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_sdl.cpp + imgui_impl_metal.cpp Compiler: Xcode Clang 12.0.5 Operating System: macOS 11.5.1

My Issue/Question:

When switching to fullscreen via the standard keyboard shortcut ⌃⌘F, the application crashes, asserting in imgui_impl_metal.mm, line 523:

                    // Apply scissor/clipping rectangle
                    MTLScissorRect scissorRect =
                    {
                        .x = NSUInteger(clip_rect.x),
                        .y = NSUInteger(clip_rect.y),
                        .width = NSUInteger(clip_rect.z - clip_rect.x),
                        .height = NSUInteger(clip_rect.w - clip_rect.y)
                    };
                    [commandEncoder setScissorRect:scissorRect]; // Asserts here

The assertion appears to come from Metal itself:

validateMTLScissorRect:2649: failed assertion (rect.x(0) + rect.width(2880))(2880) must be <= render pass width(2560)’ validateMTLScissorRect:2649: failed assertion (rect.x(0) + rect.width(2880))(2880) must be <= render pass width(2560)’

Screenshots/Video

Nothing to screenshot here as it’s not a visual bug.

Standalone, minimal, complete and verifiable example: example.zip

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

Just tried connecting an external display using HDMI. I set it as the main display and a non HDPI resolution (1024x768) and still got the issue.