Cinder icon indicating copy to clipboard operation
Cinder copied to clipboard

Some samples with ImGui crash on macOS when window is resized

Open gaborpapp opened this issue 4 years ago • 2 comments

When the window is resized or made full screen the following assertion is thrown:

Assertion failed: (g.WithinFrameScope), function Begin, file /cinder/src/imgui/imgui.cpp, line 5380.

It is reproducible with PickingFBO (resized or full screen), DeferredShading (full screen), but it does not happen with other ImGui samples like DeferredShadingAdvanced, ClothSimulation, NormalMapping, ShadowMapping.

macOS Catalina 10.15.7, latest cinder HEAD bb15730

gaborpapp avatar Apr 06 '21 14:04 gaborpapp

As far as I can tell, the new implementation doesn't have the same safeguards we had in Cinder-ImGui to prevent crashes when ImGui functions are called inside the draw function. This is probably the reason it crashes in some samples but not others.

I don't think this is a macosx issue as I can reproduce that on Windows with any code in the App draw function. The assert is usually triggered when moving or resizing the window. An easy way to reproduce this is to grab the window and drag it all the way to the side of the screen.

simongeilfus avatar Feb 16 '22 10:02 simongeilfus

Actually I think @num3ric 's PR here: https://github.com/cinder/Cinder/pull/2178/files would fix the issue on all platforms (with some small edit / removing the ifdef). The app draw function is not guarantied to be called only once for each call to the update function. This is true on Windows and on Mac (probably on Linux too?).

This in turns produces sometimes calls to ImGui::Render that are not paired with their respective ImGui::NewFrame. This produces more or less the same thing as calling ImGui::Begin without calling ImGui::End.

simongeilfus avatar Feb 16 '22 10:02 simongeilfus