You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Crash with Metal/SDL when switching to fullscreen #4414
Hello,
Thanks for reporting this.
Can you confirm it happens with our unmodified demo app?
It looks like imgui side was already told about the new framebuffer size, but underlying Metal buffers weren't setup properly.
Well if our main.mm works and not yours I guess it would make sense to try to understand the difference. Saying "there's nothing special happening" merely means "I don't understand yet what's causing this".
Given the reported issue, it feels to me that Metal and Dear ImGui are not in sync in term of display size. I don't have access to a Metal device to investigate further myself.
This doesn't appear to be limited to enabling fullscreen, it also occurs when the window is resized by the user. If you drag to make the window larger it works, but if you drag to make the window smaller it causes the same assertion to fail.
This is only an issue for me when I am running my code from Xcode in the debug mode. If I compile and execute outside of Xcode then I have no issues at all.
I have found that I can successfully get the code to run in debug mode as well by disabling metal API validation in Xcode (edit schema -> run -> metal api validation).
@Mielie what OS version are you using? Also maybe you are using a retina screen? If yes - maybe issue goes away if you switch to non-hdpi resolution in OS settings?
So far i could not replicate this issue. Im testing on 10.13 and non-hdpi screen.
@rokups The problem first started for me on Big Sur (which is when I started this project). It is still happening on Monterey (now on 12.2).
I'm using an M1 MacBook Pro, so it does have a Retina display and I've tried all the different scaled options and I still get the assert unless I disabled API validation.
Can you try unscaled resolution? It may be possible that issue stems from some incorrect handling of this scaling. Even though i could not trigger it when switching to a scaled resolution myself, maybe it is a problem which im getting saved from by my hardware somehow.
I note that this issue is now closed, and the fix in ImGui.cpp mentioned has removed the assert when you reduce the application window size, however, I am still getting the same assert when I attempt to switch the app to fullscreen.
This problem also happens with the wgpu/sdl2 backend on linux nvidia. What I've been told is that the issue lies in the timing of the window size query; it is done automatically when one begins a new sdl frame, but the size might already be different from the one used to reconfigure the surface after an attempt at acquiring the next frame image fails. Locally I've worked around this by editing the DrawData struct prior to sending it to wgpu, replacing the DisplaySize field with a canonical size I query at the beginning of the frame and is used for the surface configuration as well.
Activity
ocornut commentedon Aug 11, 2021
Hello,
Thanks for reporting this.
Can you confirm it happens with our unmodified demo app?
It looks like imgui side was already told about the new framebuffer size, but underlying Metal buffers weren't setup properly.
ocornut commentedon Aug 23, 2021
Well if our main.mm works and not yours I guess it would make sense to try to understand the difference. Saying "there's nothing special happening" merely means "I don't understand yet what's causing this".
Given the reported issue, it feels to me that Metal and Dear ImGui are not in sync in term of display size. I don't have access to a Metal device to investigate further myself.
Mielie commentedon Oct 6, 2021
I'm also having this issue. Using imgui_impl_sdl.cpp + imgui_impl_metal.cpp with clang 13.0.0 compiling on an m1 Mac.
For me this is happening with the demo program without any modifications. I am using the dockable branch.
Console error is exactly the same as described by the previous reporter.
Mielie commentedon Oct 6, 2021
This doesn't appear to be limited to enabling fullscreen, it also occurs when the window is resized by the user. If you drag to make the window larger it works, but if you drag to make the window smaller it causes the same assertion to fail.
Mielie commentedon Dec 16, 2021
This is only an issue for me when I am running my code from Xcode in the debug mode. If I compile and execute outside of Xcode then I have no issues at all.
I have found that I can successfully get the code to run in debug mode as well by disabling metal API validation in Xcode (edit schema -> run -> metal api validation).
rokups commentedon Feb 3, 2022
@Mielie what OS version are you using? Also maybe you are using a retina screen? If yes - maybe issue goes away if you switch to non-hdpi resolution in OS settings?
So far i could not replicate this issue. Im testing on 10.13 and non-hdpi screen.
Mielie commentedon Feb 3, 2022
@rokups The problem first started for me on Big Sur (which is when I started this project). It is still happening on Monterey (now on 12.2).
I'm using an M1 MacBook Pro, so it does have a Retina display and I've tried all the different scaled options and I still get the assert unless I disabled API validation.
rokups commentedon Feb 3, 2022
Can you try unscaled resolution? It may be possible that issue stems from some incorrect handling of this scaling. Even though i could not trigger it when switching to a scaled resolution myself, maybe it is a problem which im getting saved from by my hardware somehow.
Mielie commentedon Feb 3, 2022
I normally have it set to default, but I've also tried the scaled options. There doesn't seem to be a way to select a specific resolution:

rokups commentedon Feb 3, 2022
Ah... Yeah what i meant is a resolution under "Scaled" option, which does not have "HDPI" next to it. I guess you tried that already... 🤔
Mielie commentedon Feb 3, 2022
Yup, tried all the options under scaled...
Mielie commentedon Feb 3, 2022
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.
Mielie commentedon Apr 9, 2023
I note that this issue is now closed, and the fix in ImGui.cpp mentioned has removed the assert when you reduce the application window size, however, I am still getting the same assert when I attempt to switch the app to fullscreen.
radgeRayden commentedon Jan 20, 2024
This problem also happens with the wgpu/sdl2 backend on linux nvidia. What I've been told is that the issue lies in the timing of the window size query; it is done automatically when one begins a new sdl frame, but the size might already be different from the one used to reconfigure the surface after an attempt at acquiring the next frame image fails. Locally I've worked around this by editing the DrawData struct prior to sending it to wgpu, replacing the DisplaySize field with a canonical size I query at the beginning of the frame and is used for the surface configuration as well.
Backends: SDL3: use SDL_GetWindowDisplayScale() on Mac to output Disp…
ocornut commentedon Sep 15, 2025
This seems like the same as #8703.
I have now pushed a possible fix for SDL3: 22a6a83 but lacking one for SDL2 so far.