Closing secondary window (via close()) causes ci::gl::ScopedFramebuffer to crash

Hey Embers,

I’m facing an odd situation…

I’m wondering if anyone else has messed around a bit with more than one windows while using FrameBufferObjects. My application is primarily single threaded, and I’m actively rendering some visuals on to textures using various FBOs. All of these were created in the primary OpenGL context, and I’m aware that an FBO cannot be shared among two OpenGL contexts. Thus I rely on textures to render the contents.

If I close the secondary window using the close();, the program crashes. If I click the x in the top right, then it doesn’t. The place it crashes specifically is Lin 1557 in Context.cpp - the reference to the std::vector referenced by the stack variable is seemingly gone.

The final call-stack in cinder is as follows:

PlanMixPlay.exe!cinder::gl::Context::pushStackState<int>(std::vector<int,std::allocator<int> > & stack, int value) Line 1557	C++
PlanMixPlay.exe!cinder::gl::Context::pushFramebuffer(unsigned int target, unsigned int framebuffer) Line 1092	C++
PlanMixPlay.exe!cinder::gl::Context::pushFramebuffer(const std::shared_ptr<cinder::gl::Fbo> & fbo, unsigned int target) Line 1082	C++
PlanMixPlay.exe!cinder::gl::ScopedFramebuffer::ScopedFramebuffer(const std::shared_ptr<cinder::gl::Fbo> & fbo, unsigned int target) Line 173	C++

ending in an access violation.

Anyone else have any experience with this?

Regards,
Gazoo

Hey again embers,

It’s been about three years now since I posted this message, and while the error has changed, the ultimate predicament has not. To sum up the situation:

  • Application uses two windows.
  • Calling secondWindowRef->close() crashes the program after a second or so.
  • Closing the secondary window via the x in the top-right, does not.

The crash now occurs in here:

|>|PlanMixPlay.exe!cinder::gl::Context::restoreInvalidatedVao() Line 287|C++|
|---|---|---|
| |PlanMixPlay.exe!cinder::params::A0xd0b21962::`anonymous namespace'::popGlState() Line 121|C++|
| |PlanMixPlay.exe!cinder::params::`anonymous namespace'::mouseMove(std::weak_ptr<cinder::app::Window> winWeak, int twWindowId, cinder::app::MouseEvent & event) Line 191|C++|

I can see on line 287 that the mVaoStack vector contains a nullptr.

I’m sure there’s a way to mitigate the issue on my end (as opposed to digging inside Cinder), but given that there’s no crash when closing the window via the x it seems a lot like some core piece is missing or not being done when just calling close() on a window reference.

I also found this link related to the problem, but alas the suggestions in there did not help:

https://forum.libcinder.org/topic/properly-shutdown-a-multiple-window-application#23286000001938001

Cheers,
Gazoo