Hi,
I have come across a problem when performing multi-threaded rendering.
The application setup is as follows: 4 windows with 4 independent OpenGL
contexts, with 4 associated GraphicsWindowEmbedded. There are 4 threads,
invoking Viewer->frame().
After some time, 3 out of 4 threads are blocked, using gdb, I get the
deadlock locations:
2 threads are in this:
#0 0x90c5a4ee in semaphore_wait_signal_trap
#1 0x90c61fc5 in pthread_mutex_lock
#2 0x00299ffc in std::_Rb_tree<unsigned int, std::pair<unsigned int const,
ContextData>, std::_Select1st<std::pair<unsigned int const, ContextData> >,
std::less<unsigned int>, std::allocator<std::pair<unsigned int const,
ContextData> > >::insert_unique
#3 0x00295b18 in osg::GraphicsContext::getCompileContext
#4 0x0051ed05 in osgViewer::Renderer::cull_draw
#5 0x00297350 in osg::GraphicsContext::runOperations
#6 0x00521d20 in osgViewer::ViewerBase::renderingTraversals
#7 0x00003b91 in -[OSGView drawRect:] at OSGView.mm:367
#8 0x00003d7d in -[OSGView displayFrame:] at OSGView.mm:400
#9 0x00003007 in MEDisplayLinkCallback at OSGView.mm:102
#10 0x955a8013 in CVDisplayLink::performIO
#11 0x955a863f in CVDisplayLink::runIOThread
#12 0x90c8b6f5 in _pthread_start
#13 0x90c8b5b2 in thread_start
Another one in this:
#0 0x90c5a4ee in semaphore_wait_signal_trap
#1 0x90c61fc5 in pthread_mutex_lock
#2 0x00299ffc in std::_Rb_tree<unsigned int, std::pair<unsigned int const,
ContextData>, std::_Select1st<std::pair<unsigned int const, ContextData> >,
std::less<unsigned int>, std::allocator<std::pair<unsigned int const,
ContextData> > >::insert_unique
#3 0x00295b18 in osg::GraphicsContext::getCompileContext
#4 0x00060060 in osgDB::DatabasePager::requiresExternalCompileGLObjects
#5 0x0051ef88 in osgViewer::Renderer::cull_draw
#6 0x00297350 in osg::GraphicsContext::runOperations
#7 0x00521d20 in osgViewer::ViewerBase::renderingTraversals
#8 0x00003b91 in -[OSGView drawRect:] at OSGView.mm:367
#9 0x00003d7d in -[OSGView displayFrame:] at OSGView.mm:400
#10 0x00003007 in MEDisplayLinkCallback at OSGView.mm:102
#11 0x955a8013 in CVDisplayLink::performIO
#12 0x955a863f in CVDisplayLink::runIOThread
#13 0x90c8b6f5 in _pthread_start
#14 0x90c8b5b2 in thread_start
Seems to be in there:
GraphicsContext* GraphicsContext::getCompileContext(unsigned int contextID)
{
// osg::notify(osg::NOTICE)<<"GraphicsContext::getCompileContext
"<<contextID<<std::endl;
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_contextIDMapMutex);
ContextIDMap::iterator itr = s_contextIDMap.find(contextID);
if (itr != s_contextIDMap.end()) return
itr->second._compileContext.get();
else return 0;
}
I did not configure any thread specific flags in OSG (perhaps I should have
done that?), I am not familiar with how OSG handles threading.
I also cannot instrument OSG to debug this as I am using precompiled
binaries (OSX frameworks), OSG 2.2.0-10.5SDK.
I can workaround this by making all rendering mutually exclusive, but this
is obviously not what I want.
Any advice would be greatly appreciated. Thanks,
Raphael
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org