<div dir="ltr"><div dir="ltr">Hi Martin,<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 26 Jul 2019 at 11:41, Martin Siggel <<a href="mailto:martinsiggel%2Bosg@gmail.com">martinsiggel+osg@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Hi Robert,<div dir="auto"><br></div><div dir="auto">I had a custom camera manipulator, which was derived from orbitmanipulator.</div><div dir="auto"><br></div><div dir="auto">I experienced the issue in my Android app. I assigned this manipulator to the osgviewer and kept a reference outside of the viewer. My idea was to keep the current state of orbit animation and position when going back to the app.</div><div dir="auto"><br></div><div dir="auto">However, this prevented cleaning up all the GL objects from the current context, even though I deleted the viewer. After removing the reference to the manipulator, everything worked as expected.</div></div></blockquote><div><br></div><div>Using an osg::observer_ptr<> might be the best solution for this type of usage.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="auto">Therefore, I suppose that there has to be some reference to the camera in the manipulator.</div></div></blockquote><div><br></div><div>There isnt' any need to have an explict link to the Camera as the higher level functionality passes in the CameraManipulator::updateCamera(osg::Camera& camera) method.  This means it's possible to use the same CameraManipulator with multiple Camera i.e. have multiple View's but each share the same CameraManipualator. <br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="auto">I could provide an example but it will be an Android example. Is there something you could use?</div></div></blockquote><div><br></div><div>I don't have a Android setup yet so such an example won't help too much.  In your case I think it's just more careful management of objects that is required rather than a bug in the core OSG that needs to be resolved.</div><div><br></div><div>This whole issue stems from a limitation with OpenGL and how you can only do clean up from a graphics thread associated with graphics context, and once a window closes it's graphics context is no longer valid so any handles you have to the objects held in that context are now invalid.  This means you have to juggle who and when gets to clean up the gl objects and the handle to them.<br></div><div><br></div><div>In the Vulkan/VSG the objects are mostly associate with a device context rather than a window so it's possible to have windows come and go and still manage the lifetime of the objects in a straight forward way.  Or at least I've been able to hide the lifetime issue in a far easier and more robust to different usage cases way.  On the OSG side it's usage cases on the edges of the usual way that the OSG does things is when problems arise.<br></div><div><br></div><div>Robert.<br></div></div></div>