【ZeloEngine】ImGui调试
docking窗口合并时Assertion Failed
报错分析
Assertion failed: (g.CurrentWindowStack.Size == 1) && "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?", file C:\Users\zoloypzuo\Documents\GitHub\ZeloEngine\Dep\src\imgui\imgui.cpp, line 7903
Begin和End没有成对
定位问题
这种问题怎么查呢?Begin和End很多,而且是某一帧发生的
其实和GL调试有一定相似性,最原始的方法是hook所有GL调用,把函数名和参数打印出来
Zelo所有imgui逻辑都是导出lua的,所以很好做hook
这里可以hook特定imgui call,也就是Begin和End
ENABLE_HOOK_DEBUG_IMGUI = true
if ENABLE_HOOK_DEBUG_IMGUI then
local _ImGui = {}
for name, fn in pairs(ImGui) do
_ImGui[name] = function(...)
print("ImGui." .. name, ...)
return fn(...)
end
end
ImGui = _ImGui
end
然后启动游戏,复现问题
日志打出来了
[18:18:44.928] [lua] [debug] main_initialize.lua(73,1) ImGui.BeginMenu Window true
[18:18:44.944] [lua] [debug] main_initialize.lua(73,1) ImGui.BeginMenu Entity true
[18:18:44.960] [lua] [debug] main_initialize.lua(73,1) ImGui.BeginMenu Resources true
[18:18:44.976] [lua] [debug] main_initialize.lua(73,1) ImGui.BeginMenu Layout true
[18:18:44.992] [lua] [debug] main_initialize.lua(73,1) ImGui.BeginMenu Tool true
[18:18:45.008] [lua] [debug] main_initialize.lua(73,1) ImGui.BeginMenu Help true
[18:18:45.024] [lua] [debug] main_initialize.lua(73,1) ImGui.BeginMenu Sandbox true
[18:18:45.040] [lua] [debug] main_initialize.lua(73,1) ImGui.EndMainMenuBar
[18:18:45.056] [lua] [debug] main_initialize.lua(73,1) ImGui.SetNextWindowSizeConstraints 0 0 10000 10000
[18:18:45.072] [lua] [debug] main_initialize.lua(73,1) ImGui.Begin Hierarchy##2 true 32792
[18:18:45.088] [lua] [debug] main_initialize.lua(73,1) ImGui.SetNextWindowSizeConstraints 0 0 10000 10000
[18:18:45.104] [lua] [debug] main_initialize.lua(73,1) ImGui.Begin Inspector##3 true 32792
[18:18:45.120] [lua] [debug] main_initialize.lua(73,1) ImGui.End
Assertion failed: (g.CurrentWindowStack.Size == 1) && "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?", file C:\Users\zoloypzuo\Documents\GitHub\ZeloEngine\Dep\src\imgui\imgui.cpp, line 7903
截取最后两帧的日志做diff
发现是Hierarchy没有调用End
结论
imgui的Window的Begin/End不需要检查if
|