MangoHud icon indicating copy to clipboard operation
MangoHud copied to clipboard

[Crash] when multiple windows from the same process are ovelayed by mangohud

Open xzn opened this issue 9 months ago • 2 comments

Describe the bug Have an app that opens multiple vulkan windows. Mangohud sometimes crash the process with:

../MangoHud-v0.8.1/subprojects/imgui-1.89.9/imgui_draw.cpp:4117: unsigned int stb_decompress(unsigned char*, const unsigned char*, unsigned int): Assertion `stb__dout <= output + olen' failed.

during window resize.

Other possible error message during crash:

../MangoHud-v0.8.1/subprojects/imgui-1.89.9/imgui.cpp:6223: bool ImGui::Begin(const char*, bool*, ImGuiWindowFlags): Assertion `g.WithinFrameScope' failed.

Sometimes crashes without error message, gdb backtrace shows:

... in ImGui::SetCursorPosX (x=154) at ../MangoHud-v0.8.1/subprojects/imgui-1.89.9/imgui.cpp:9619                          
9619        window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + x;

Note The app renders to each vulkan window with one separate thread, with separate VkDevice created from the same VkInstance. Crash happens more reliably on x11 but happens on pure wayland/xwayland as well.

List relevant hardware/software information

  • MangoHud version: v0.8.1

Expected behavior Doesn't crash

Relate note Vulkan validation layer often reports the following during window resize when mangohud is enabled:

vkCreateSwapchainKHR(): pCreateInfo->presentMode (VK_PRESENT_MODE_FIFO_KHR) is not supported (the following are supported ).
The Vulkan spec states: presentMode must be one of the VkPresentModeKHR values returned by vkGetPhysicalDeviceSurfacePresentModesKHR for the surface (https://docs.vulkan.org/spec/latest/chapters/VK_KHR_surface/wsi.html#VUID-VkSwapchainCreateInfoKHR-presentMode-01281)

This is harmless so long as the error is handled by the app, but it's weird that present modes are disappeared sometimes during window resize when enabling mangohud.

xzn avatar Apr 02 '25 19:04 xzn

Have an app that opens multiple vulkan windows

Do you have an example app that we could test this with?

flightlessmango avatar Apr 04 '25 10:04 flightlessmango

Hi,

I've realized this is a niche use case, as on Windows MSI Afterburner has the same issue. If you want to look into it though, I have an example here:

https://github.com/xzn/Nuklear/tree/sdl_vulkan_multiple_window/demo/sdl_vulkan_multiple_windows (The actual program start at line 2080 of main.c, rest is boilerplate.)

Can be built by running make, the binary will at bin/demo

Compiled binary (has asan and SDL2 dependencies):

demo.tar.gz

The application that I'm developing (which uses multiple windows for output) only mostly crashes during resize. The sdl example just linked however seems to crash during present, basically it appears to be global imgui data structure/variables being used at the same time from different threads.

xzn avatar Apr 04 '25 15:04 xzn