Discussion:
[osg-users] [Crash issue] How to add&remove drawable (geometry) property.
Jinh Tang
2018-07-26 10:10:45 UTC
Permalink
Hi,
I am doing them real-time rendering application development with Qt + OSG.
I created several threads to create new Geometry and in GUI - main threads, try to remove the old one and add new ones.

1, already set node and geometry to user dynamic.
geometry->setDataVariance(osg::Object::DYNAMIC)
geode_->setDataVariance(osg::Object::DYNAMIC);
2, already used osg smart point everywhere.
3, geometry is created in other threads. and post to a global queue.
4, in Main thread. PaintGL event will add&remove geometry in "autoAddRemove" function.
void OSGMeshRender::paintGL() {
autoAddRemove();
viewer_->frame();
}
5, the setup work for qt+osg is almost same like this blog, nothing speical.
vicrucann.github.io/tutorials/cmake-qt-osg-1/


I got below crash sometimes when I add&remove drawable.

0000082`873ba218 : nvoglv64+0x927b51
00000075`2b19bf61 : osg156_osgrd!osg::GLBufferObject::deleteGLObject+0x69 [c:\users\code\openscenegraph-openscenegraph-3.6.0\src\osg\bufferobject.cpp @ 253]
00000075`2b19bf61 : osg156_osgrd!osg::GLBufferObjectSet::flushDeletedGLBufferObjects+0x25e [c:\users\code\openscenegraph-openscenegraph-3.6.0\src\osg\bufferobject.cpp @ 554]
0000018c`3829dc50 : osg156_osgrd!osg::GLBufferObjectManager::flushDeletedGLObjects+0x7e [c:\users\code\openscenegraph-openscenegraph-3.6.0\src\osg\bufferobject.cpp @ 984]
*** WARNING: Unable to verify checksum for osg156-osgUtilrd.dll
0000018c`2e070d90 : osg156_osgrd!osg::ContextData::flushDeletedGLObjects+0x65 [c:\users\code\openscenegraph-openscenegraph-3.6.0\src\osg\contextdata.cpp @ 88]
*** WARNING: Unable to verify checksum for osg156-osgViewerrd.dll
0000018c`37fcbb60 : osg156_osgUtilrd!osgUtil::SceneView::draw+0xdb [c:\users\code\openscenegraph-openscenegraph-3.6.0\src\osgutil\sceneview.cpp @ 987]
0000018d`01da2350 : osg156_osgViewerrd!osgViewer::Renderer::cull_draw+0x309 [c:\users\code\openscenegraph-openscenegraph-3.6.0\src\osgviewer\renderer.cpp @ 887]
00000000`00000000 : osg156_osgrd!osg::GraphicsContext::runOperations+0x99 [c:\users\code\openscenegraph-openscenegraph-3.6.0\src\osg\graphicscontext.cpp @ 696]
00000000`000003f9 : osg156_osgViewerrd!osgViewer::ViewerBase::renderingTraversals+0xc2d [c:\users\code\openscenegraph-openscenegraph-3.6.0\src\osgviewer\viewerbase.cpp @ 8
00000000`000003f9 :
osg156_osgViewerrd!osgViewer::ViewerBase::frame

attached windbg callstack.


any suggestion? fully appreciate!!!
...

Thank you!

Cheers,

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74388#74388
Robert Osfield
2018-07-26 13:36:26 UTC
Permalink
Hi Jinh,

First thing I would try is to run your application single threaded.
If this fixes the crash then it would indicate a threading issue with
how you are going about adding/remove elements of the scene graph.

You don't describe any of details of what threads are doing what so I
can't speculate any further as to what you might be doing wrong. As a
general guide, the OSG is designed for the main scene graph to be
updated only in the update and event phases/traversals where the scene
graph itself is being traversed single threaded.

Robert.
Post by Jinh Tang
Hi,
I am doing them real-time rendering application development with Qt + OSG.
I created several threads to create new Geometry and in GUI - main threads, try to remove the old one and add new ones.
1, already set node and geometry to user dynamic.
geometry->setDataVariance(osg::Object::DYNAMIC)
geode_->setDataVariance(osg::Object::DYNAMIC);
2, already used osg smart point everywhere.
3, geometry is created in other threads. and post to a global queue.
4, in Main thread. PaintGL event will add&remove geometry in "autoAddRemove" function.
void OSGMeshRender::paintGL() {
autoAddRemove();
viewer_->frame();
}
5, the setup work for qt+osg is almost same like this blog, nothing speical.
vicrucann.github.io/tutorials/cmake-qt-osg-1/
I got below crash sometimes when I add&remove drawable.
0000082`873ba218 : nvoglv64+0x927b51
*** WARNING: Unable to verify checksum for osg156-osgUtilrd.dll
*** WARNING: Unable to verify checksum for osg156-osgViewerrd.dll
osg156_osgViewerrd!osgViewer::ViewerBase::frame
attached windbg callstack.
any suggestion? fully appreciate!!!
...
Thank you!
Cheers,
------------------
http://forum.openscenegraph.org/viewtopic.php?p=74388#74388
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Jinh Tang
2018-07-26 13:55:40 UTC
Permalink
Hi Robert,
thanks a lot! I tried single thread, but it can meet project requirement, as we may have 500+ meshes need to update. each mesh has 12000+ points. the main GUI thread will be blocked for 10+ seconds....
besides, I already set the viewer to use SingleThreaded. paste my code of initialization below:

graphics_window_ = (new osgViewer::GraphicsWindowEmbedded(x, y, width, height) );
viewer_ = new osgViewer::Viewer;
scale_ = QApplication::desktop()->devicePixelRatio();
root_ = new osg::Group;

mouse_trans_ = new osg::PositionAttitudeTransform;
root_->addChild(mouse_trans_);

// init camera
camera_ = new osg::Camera();
//camera_ = viewer_->getCamera();
camera_->setClearMask(GL_DEPTH_BUFFER_BIT);
camera_->setClearMask(GL_COLOR_BUFFER_BIT);
camera_->setViewport(x, y, width, height);
camera_->setClearColor( osg::Vec4( 0.91f, 0.91f, 0.91f, 1.f ) );
float aspectRatio = static_cast<float>(width) / static_cast<float>(height);
camera_->setProjectionMatrixAsOrtho(-DEFAULT_ORTHO_RANGE * aspectRatio, DEFAULT_ORTHO_RANGE * aspectRatio, -DEFAULT_ORTHO_RANGE, DEFAULT_ORTHO_RANGE, -500.0, 500.0);
camera_->setGraphicsContext( graphics_window_ );

viewer_->setCamera(camera_);

camera_->addChild(root_);
viewer_->setSceneData(root_);

camera_manipulator_ = new MeshCameraManipulator(camera_, osg::Vec3(0, 0, 100), osg::Vec3(0, 0, 0), osg::Vec3(0, 1, 0), mouse_trans_);
camera_manipulator_->Setup(this);
camera_manipulator_->SetWindowSize(width, height);
viewer_->setCameraManipulator(camera_manipulator_);
viewer_->setThreadingModel(osgViewer::Viewer::SingleThreaded);

viewer_->realize();

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

Loading...