pioneerspacesim / pioneer

A game of lonely space adventure
https://pioneerspacesim.net
1.65k stars 380 forks source link

Crash in ImFontAtlas::~ImFontAtlas at application exit #4502

Closed etam closed 5 years ago

etam commented 5 years ago

Observed behaviour

Game crashes when closing, with message:

pioneer: imgui_draw.cpp:1411: ImFontAtlas::~ImFontAtlas(): Assertion `!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"' failed.

This was already reported at #4309 (it was suggested that it should be tracked in a separate issue, so I'm making this one)

Expected behaviour

Guess :)

Steps to reproduce

My pioneer version (and OS):

20181223 (openSUSE Tumbleweed, snapshot 20181218)

sturnclaw commented 5 years ago

Thanks for opening this one, @etam. I've (mostly) tracked it down to Pi.cpp; the game's shutdown process interrupts the middle of a frame and starts deleting things (including PiGui / IMGUI) before the frame is finished, generating this error.

Resolving this is a semi-major architectural change, so it's slated for the next time I try moving stuff out of the Pi monolith. However, anyone reading this is more than free to fix it themselves whenever they want; just remember to send in the PR, please :wink:.

fluffyfreak commented 5 years ago

We shouldn't really be doing processing in methods on UI callbacks but it's such a convenient way of working that we always do it. I've added the start of a simple request queue so that UI responses can just queue up something instead.

This is then processed in the main loop. Much safer way of dealing with things.

sturnclaw commented 5 years ago

Sounds good. We'll probably be using entt for the ECS (and potentially to phase out sigc++, for less dependency issues); there might be something for event queues in the bag-o-tricks that library is.

senderghost commented 5 years ago

I tested changes in #4503 on FreeBSD (10.4 amd64; LLVM/Clang v6.0.1 from devel/llvm60 port) and they work, i.e. the application didn't output mentioned assertion message in console after quit and didn't crash.