cinder / Cinder

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

ImGui assertion fails at resize event on macOS #2173

Open miko007 opened 4 years ago

miko007 commented 4 years ago

If one resizes the window on macOS and ImGui is used, the cinder app crashes, because the assertion g.WithinFrameScope fails. To fix this, line 528 (commit cd1d70191a4a62e9a303c620271e0341758cdf04) in src/cinder/CinderImGui.cpp

https://github.com/cinder/Cinder/blob/cd1d70191a4a62e9a303c620271e0341758cdf04/src/cinder/CinderImGui.cpp#L528 hast to be changed to

    sWindowConnections[window] += window->getSignalDraw().connect( std::bind( ImGui_ImplCinder_NewFrameGuard, window ) );

As of the huge backlog of pull requests, i will not open another one. Maybe one of the developers can implement this little fix directly.

num3ric commented 4 years ago

Hi @miko007, thanks for the report. Unfortunately, I don't have access to a mac with Xcode to replicate this issue at the moment.

However, using the window's draw signal would prevent the use of Dear ImGui in the app update() function (a common pattern for small apps/samples). Using ImGui:: functions there would then also result in the same g.WithinFrameScope assertion error.

A platform-specific fix may instead affect the ImGui_ImplCinder_Resize or the ImGui_ImplCinder_NewFrameGuard functions, but hard to tell from afar.

miko007 commented 4 years ago

that is correct, while i am not shure why one could not do the gui in App::draw() instead, because thats what it is for, right?

But if that is a concern, i am not really shure how to proceed from here, as ImGui is pretty much not usable on macOS without the fix...

num3ric commented 4 years ago

Got my hands on a Mac so I'll be able to take a look soon.

davidgranstrom commented 3 years ago

I also noticed this issue on macOS when trying out Cinder. I rebuilt the library with the patch from #2178 and resizing (with ImGui) seem to work fine now!