mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-16 19:11:13 +00:00
Crash in Metal backend/docking branch (and fix) #4464
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#4464
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Version/Branch of Dear ImGui:
Version: git latest
Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_metal.cpp + imgui_impl_osx.cpp
Compiler: clang/Xcode 11
Operating System: Big Sur
My Issue/Question:
Attempting to dock a window at the bottom of the screen results in a render encoder crash, at the moment the dragged window begins clipping against the bottom of the screen, because the calculated scissor window extends beyond the surface bounds.
Screenshots/Video
Standalone, minimal, complete and verifiable example: (see https://github.com/ocornut/imgui/issues/2261)
Here's the fix, which I believe belongs in all branches.
With this fix, my application does not crash and window rendering is as expected as it intersects the bottom of the screen.
Hello,
Thanks for the report.
Could it be the same as #4414 ? (despite the same error/same line, i believe #4414 miiight be caused by something else)
(1)
I'm not sure I understand this well (I don't have a machine to run Metal) but even before digging, this line which was ALREADY there seems fishy to me:
GL and Vulkan backends also have this. It was merged in as part of a refactor
85f9694bdand initially added by early viewports work here:3bd3693f. We shouldn't need those IHMO, so that's something we'll investigate.(2)
As for your specific issue, will need further investigation as well.
Could you report what the value for
draw_data->DisplayPosanddraw_data->DisplaySizeare when the assertion triggers, as well as the specific values of that assertion in that session.It could be that the timing of update for those with those backends makes dear imgui render for previous position and previous size?
Hey @meshula, could you clarify what does this mean exactly? Do you mean a bottom of main viewport or a bottom of your desktop? Also do you experience this issue with one of examples or do you only experience it in your application, but not in any of examples? Could you record a video showcasing how to reproduce this issue? So far i was unable to reproduce it and im not sure if i misunderstood something or if this stems from a difference of OS version (i tested on High Sierra).
I should have made the video first, sorry about that.
I am using the bundled example program, to which I have added the ImGuizmo ImSequencer, and slight boilerplate to enable docking.
Ah, it's a bug in the ImSequencer. All other panels dock properly.
I notice now that there are a couple of open issues on ImSequencer arguing that the clip region is not calculated properly.
So my patch works around a bug in ImSequencer, apparently?
https://github.com/CedricGuillemet/ImGuizmo/pull/57
https://github.com/CedricGuillemet/ImGuizmo/pull/195
So I think that there is no bug in Dear ImGui, hopefully Cedric can catch the issue on his side, but,,,, this patch lets me not crash with Cedric's code. Maybe I should maintain it as a local patch for now?
https://user-images.githubusercontent.com/501238/130524143-a5b65370-d812-41f2-9d37-c4cad73148a2.mov
PS, I can't reproduce the full screen issue in #4414, so I don't think the issue I am reporting is related to latency in the fbsize update.
I can reproduce the issue by doing this in our standard example:
Crash can be worked around by adding:
Maybe a proper fix would be getting rid of that fishy if and just clamping clip rect to available dimensions?
Yes, could you investigate the result of that test case over all our backend?
Also worth adding a test like that (it's not going to run over all backends, but better than nothing)
Still is a bug in Dear ImGui ihmo, we shouldn't be able to crash the backend.
It's just that the core library behave "too well" in term of pushing clipping rectangle (*) and thus this wasn't exercised properly.
* Because the ImGui:: side of PushClipRect will alter coarse clipping of items as well, it is very much preferable to behave well.
Pushed fixes:
2b0bd40b99And standardized handling across backends a bit better (but only clamping but API that needs it)
Thanks for the investigation and fix, much appreciated!