cinder / Cinder

Cinder is a community-developed, free and open source library for professional-quality creative coding in C++.
http://libcinder.org
Other
5.27k stars 939 forks source link

Some samples with ImGui crash on macOS when window is resized #2236

Open gaborpapp opened 3 years ago

gaborpapp commented 3 years ago

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

simongeilfus commented 2 years ago

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 commented 2 years ago

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.