[osg-users] [Any feedback welcome] possible lack of robustness of the VAO path

Julien Valentin julienvalentin51 at gmail.com
Sun Jan 20 06:09:16 PST 2019


poison
https://github.com/openscenegraph/OpenSceneGraph/issues/694
remedy (propal)
https://github.com/openscenegraph/OpenSceneGraph/pull/695


mp3butcher wrote:
> Hi
> releaseGLObject didn't fix the issue (even in SingleThreaded)...
> As I said, it only concern VAO path
> Cheers
> 
> 
> robertosfield wrote:
> > You have created a scheme where you are caching a nodes that can't be
> > seen directly by the viewer so it isn't able to do the normal clean up
> > that it does prior to cleaning up the graphics contexts.  Try doing a
> > releasreGLObjects() on the nodes cached on the callback prior to
> > removing them.  You also need to add a mutex to the callback as it's
> > potentially run multi-threaded.
> > 
> > On Sat, 19 Jan 2019 at 01:04, Julien Valentin
> > <> wrote:
> > 
> > > 
> > > The following code exibits crashes with VAO path
> > > 
> > > Code:
> > > 
> > > #include <osgUtil/MeshOptimizers>
> > > #include <osgGA/TrackballManipulator>
> > > #include <osgGA/FirstPersonManipulator>
> > > 
> > > #include <osgViewer/Viewer>
> > > #include <osgViewer/ViewerEventHandlers>
> > > 
> > > #include <osgDB/ReadFile>
> > > #include <osgDB/WriteFile>
> > > 
> > > 
> > > class GeomLoaderCB : public osg::Camera::DrawCallback//  osg::NodeCallback
> > > {
> > > public:
> > > int _thresremoval;int _nbaddedatatime;
> > > GeomLoaderCB(int thresremoval=1,int nbaddedatatime=1):_nbaddedatatime(nbaddedatatime),_thresremoval(thresremoval) {}
> > > mutable std::list<osg::ref_ptr<osg::Geometry> > _geoms;
> > > void setGeometryList(osgUtil::GeometryCollector::GeometryList c) {
> > > for(auto f : c)
> > > _geoms.push_back(f);
> > > }
> > > virtual void operator () (const osg::Camera&  camera ) const {
> > > osg::Node * node=const_cast<osg::Camera*>(&camera)->getChild(0);
> > > 
> > > if(_geoms.empty())return;
> > > osg::ref_ptr<osg::Group>  gr = node->asGroup();
> > > 
> > > if(gr->getNumChildren()>_thresremoval)
> > > {
> > > OSG_WARN<<"removing "<<  gr->getChild(0)<<std::endl;
> > > gr->removeChildren(0,1);
> > > return;
> > > }
> > > 
> > > std::list<osg::ref_ptr<osg::Geometry> > ::iterator it= _geoms.begin();
> > > int cpt=0;
> > > while(it!=_geoms.end()&&cpt++<_nbaddedatatime ) {
> > > gr->addChild((osg::Drawable*) (*it)->clone(osg::CopyOp::DEEP_COPY_ALL));
> > > OSG_WARN<<"add "<<  (*it ) ->getVertexArray()->getNumElements()<<std::endl;
> > > it=_geoms.erase(it);
> > > }
> > > return;
> > > }
> > > 
> > > };
> > > 
> > > 
> > > /// This demo reproduce a bug with OSG_VERTEX_BUFFER_HINT=VAO
> > > /// it collecte drawables given in arg then add and remove them at runtime
> > > int main(int argc, char **argv)
> > > {
> > > osg::ArgumentParser args(&argc,argv);
> > > unsigned int  geomcountaddedatatime=1,geomcountabovewichweremove=1;
> > > while(args.read("--add",geomcountaddedatatime) ) { }
> > > while(args.read("--remove",geomcountabovewichweremove) ) { }
> > > osgUtil::GeometryCollector geomcollector(0,osgUtil::Optimizer::ALL_OPTIMIZATIONS);
> > > 
> > > args.getApplicationUsage()->setApplicationName(args.getApplicationName());
> > > 
> > > osg::ref_ptr<osg::Node > loaded=osgDB::readNodeFiles(args);
> > > if(loaded.valid())
> > > {
> > > loaded->accept(geomcollector);
> > > 
> > > osg::Group * root=new osg::Group;
> > > //osg::Camera * root=new osg::Camera;
> > > GeomLoaderCB * loader=new GeomLoaderCB(geomcountabovewichweremove,geomcountaddedatatime);
> > > loader->setGeometryList(   geomcollector.getGeometryList() );
> > > 
> > > osgViewer::Viewer viewer;
> > > viewer.addEventHandler(new osgViewer::StatsHandler);
> > > viewer.addEventHandler(new osgViewer::WindowSizeHandler);
> > > viewer.addEventHandler(new osgViewer::ThreadingHandler);
> > > 
> > > viewer.realize();
> > > viewer.setSceneData( root);
> > > 
> > > viewer.getCamera()->setFinalDrawCallback(loader);
> > > loaded=0;
> > > 
> > > viewer.run();
> > > }
> > > }
> > > 
> > > 
> > > 
> > > 
> > > if you want my test sample:
> > > https://drive.google.com/file/d/0BxIH-jcsgYDdTG5ha21HZE1jX1E/view?usp=sharing
> > > for ex It fails  with args :
> > > BIGCITY.ive --remove 150 --add 100
> > > 
> > > I believe there's a bug....so I'd be glad if someone validate it...
> > > note: toggling statshandler prevent crash
> > > 
> > > Thanks in advance
> > > Cheers
> > > 
> > > 
> > > 
> > > 
> > > mp3butcher wrote:
> > > 
> > > > Hi all,
> > > > I wrote a sample code exibiting crash with my scene
> > > > https://github.com/openscenegraph/OpenSceneGraph/issues/692
> > > > 
> > > > If you'd have 5 min to waste, i would be glad you confirm with your own scene...
> > > > 
> > > > Thank you!
> > > > 
> > > > Cheers,
> > > > Julien
> > > > 
> > > 
> > > 
> > > ------------------------
> > > Twirling twirling twirling toward freedom
> > > 
> > > ------------------
> > > Read this topic online here:
> > > http://forum.openscenegraph.org/viewtopic.php?p=75508#75508
> > > 
> > > 
> > > 
> > > 
> > > 
> > > _______________________________________________
> > > osg-users mailing list
> > > 
> > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > > 
> > _______________________________________________
> > osg-users mailing list
> > 
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > 
> >  ------------------
> > Post generated by Mail2Forum
> 


------------------------
Twirling twirling twirling toward freedom

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75516#75516







More information about the osg-users mailing list