Re: [osg-users] getOrCreateStateSet called from outside the main thread
Hi, I've been away for two weeks, and now returning to this issue. Just wanted to update in case my findings are useful to others. On further investigation, I realised that calling getOrCreateStateSet on a newly created text node will return a pointer to a 'singleton' instance of a stateset. I had assumed that after creating the text node, the above call would 'Create' a new stateset rather than 'Get' an existing one - so I think some of our crashes are due to the same stateset pointer being written to on different threads. We're in the process of rationalising how we use statesets in our app. so we can reusing a singleset - this should resolve our issue. Thanks again Paul -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=43152#43152 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] getOrCreateStateSet called from outside the main thread
Hi, I'm hoping someone can shed some light on an issue we are having, running OSG 2.8.2 (redhat 5.3) in single threaded mode and creating scenegraph components on a background thread. Basically, we are using a background thread to build up scenegraph components and then adding them to our 'main' scenegraph. For the most part, this works fine, but when the activity on the background and main threads are high (eg. a lot of stuff moving around/ being drawn in the main scene, plus lots of updates happening on our background thread) we are seeing occasional crashes in setAssociatedModes() and other stateset related functions. My first thought was that somehow our calls to getOrCreateStateSet() from our background thread were interfering with state set manipulation on the main thread, indeed replacing getOrCreateStateSet with a call to explicitly create the stateset appears to resolve the crash. Can anyone confirm whether calling getOrCreateStateSet() outside the main thread is a safe / sensible thing to do? As I say, I have what appears to be a fix for the problem, but it would be nice to understand what is going wrong before progressing it. Thanks in advance for any help. Cheers, Paul -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42603#42603 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] getOrCreateStateSet called from outside the main thread
Hi Paul, Node/Drawable::getOrCreateStateSet() isn't thread safe so should only be called from a single thread, or called from threads that serialize access to it. If you are calling getOrCreateStateSet() on objects managed by your background thread then this should be fine, but if you are calling getOrCreateStateSet() on objects in the main scene graph from the background thread then you will have problems. Robert. On Mon, Sep 12, 2011 at 10:39 AM, paul graham pd...@hotmail.com wrote: Hi, I'm hoping someone can shed some light on an issue we are having, running OSG 2.8.2 (redhat 5.3) in single threaded mode and creating scenegraph components on a background thread. Basically, we are using a background thread to build up scenegraph components and then adding them to our 'main' scenegraph. For the most part, this works fine, but when the activity on the background and main threads are high (eg. a lot of stuff moving around/ being drawn in the main scene, plus lots of updates happening on our background thread) we are seeing occasional crashes in setAssociatedModes() and other stateset related functions. My first thought was that somehow our calls to getOrCreateStateSet() from our background thread were interfering with state set manipulation on the main thread, indeed replacing getOrCreateStateSet with a call to explicitly create the stateset appears to resolve the crash. Can anyone confirm whether calling getOrCreateStateSet() outside the main thread is a safe / sensible thing to do? As I say, I have what appears to be a fix for the problem, but it would be nice to understand what is going wrong before progressing it. Thanks in advance for any help. Cheers, Paul -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42603#42603 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] getOrCreateStateSet called from outside the main thread
Hi, Thanks for the reply Robert - just to confirm, we are indeed calling getOrCreateStateSet on nodes created in the same thread and not back in the main thread, so as you say, it should work fine. I shall run our app against a debug version of osg and try and get some more details of the crash (last two crashes were in osg::StateAttribute::removeParent(), but this seems to vary between runs). Many Thanks Paul -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42629#42629 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org