Re: [osg-users] Bug in RenderBin (?)
2009/3/23 Christof Krüger o...@christof-krueger.de Sorry for the delay. I've tested the posted code and it seems to work! I'm afraid your new email has started a new thread... so one will have to do manual searches to know exactly what you might be on about... could you give us some more clues I did merge some changes to the destruction of RenderBin's, is this the code? Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Bug in RenderBin (?)
I'm afraid your new email has started a new thread... so one will have to do manual searches to know exactly what you might be on about... could you give us some more clues I did merge some changes to the destruction of RenderBin's, is this the code? Sorry abut this, I'm using the forum and have no clue what went wrong. What I meant was the code posted by ledocc (David Callu) on Marth, 13th in the Bug in RenderBin (?) thread. He asked me to test the code and it worked fine. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9008#9008 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Bug in RenderBin (?)
Hi Christof, Hi Robert Christof talk about the thread Bug in RenerBin (?) in date of 13 march 2009 - herehttp://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/41482 for the last message herehttp://article.gmane.org/gmane.comp.graphics.openscenegraph.user/41604 Robert, Your code seem to work fine. Cheer David 2009/3/23 Christof Krüger o...@christof-krueger.de I'm afraid your new email has started a new thread... so one will have to do manual searches to know exactly what you might be on about... could you give us some more clues I did merge some changes to the destruction of RenderBin's, is this the code? Sorry abut this, I'm using the forum and have no clue what went wrong. What I meant was the code posted by ledocc (David Callu) on Marth, 13th in the Bug in RenderBin (?) thread. He asked me to test the code and it worked fine. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9008#9008 ___ 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] Bug in RenderBin (?)
Changing the removeRenderBinPrototype to use the binName instead of the classname fixes the crash. For this, you need to also add a member string variable to the Proxy object in order to remember the binName. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=8445#8445 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Bug in RenderBin (?)
Hi Christof Robert prefer search the RenderBin instance that you want to remove instead of search the name of a render bin. like this : void RenderBin::removeRenderBinPrototype(RenderBin* proto) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list proto) { for(RenderBinPrototypeList::iterator itr = list-begin(); itr != list-end(); ++itr) { if (itr-second.get() == proto) { list-erase(itr); return; } } } } Can you test this solution ? David 2009/3/13 Christof Krüger osgfo...@tevs.eu Changing the removeRenderBinPrototype to use the binName instead of the classname fixes the crash. For this, you need to also add a member string variable to the Proxy object in order to remember the binName. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=8445#8445 ___ 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] Bug in RenderBin (?)
Christof Krüger wrote: I'm using the current 2.8.0 stable release. I used the 'Browse Source' to check the current trunk version of RenderBin.cpp and I see no change since. The actual crash occurs later in static object destruction when s_renderBinPrototypeList is destructed itself. I don't understand enough of osg to know what's exactly wrong. However, the s_registerDepthSortedBinProxy doesn't release the object it created and this looks very suspicious to me. The fact that two different instances of RenderBin get registered under the same name indeed smells fishy :) Paul ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Bug in RenderBin (?)
Hi Paul, Hi Christof What is smells fishy is the use of proto-className() to identify the renderBin prototype to remove in removeRenderBinPrototype(); code void RenderBin::removeRenderBinPrototype(RenderBin* proto) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list proto) { // something wrong there RenderBinPrototypeList::iterator itr = list-find(proto-className()); if (itr != list-end()) list-erase(itr); } } /code proto-className() return always RenderBin because this is the name of the class :). Instead, in void RenderBin::removeRenderBinPrototype(RenderBin* proto) we need something like this code void RenderBin::removeRenderBinPrototype(const std::string binName, RenderBin* proto) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list proto) { RenderBinPrototypeList::iterator itr = list-find(binName); if (itr != list-end()) list-erase(itr); } } /code Thought ? David Callu 2009/3/12 Paul Melis p...@science.uva.nl Christof Krüger wrote: I'm using the current 2.8.0 stable release. I used the 'Browse Source' to check the current trunk version of RenderBin.cpp and I see no change since. The actual crash occurs later in static object destruction when s_renderBinPrototypeList is destructed itself. I don't understand enough of osg to know what's exactly wrong. However, the s_registerDepthSortedBinProxy doesn't release the object it created and this looks very suspicious to me. The fact that two different instances of RenderBin get registered under the same name indeed smells fishy :) Paul ___ 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] Bug in RenderBin (?)
HI David Christof et. al, On Thu, Mar 12, 2009 at 10:13 AM, David Callu led...@gmail.com wrote: What is smells fishy is the use of proto-className() to identify the renderBin prototype to remove in removeRenderBinPrototype(); Well spotted David, the addRenderBinPrototype() correctly uses binName, while the removeRenderBinProtoype() attempts to use the className() as it's binName. The later is definitely a bug, and one that is easy to fix... Instead, in void RenderBin::removeRenderBinPrototype(RenderBin* proto) we need something like this code void RenderBin::removeRenderBinPrototype(const std::string binName, RenderBin* proto) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list proto) { RenderBinPrototypeList::iterator itr = list-find(binName); if (itr != list-end()) list-erase(itr); } } /code Thought ? There is no need to use the binName, one just needs to search for the pointer in the map by hand, and remove it. I'm just tested the following code and it looks to be working properly : void RenderBin::removeRenderBinPrototype(RenderBin* proto) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list proto) { for(RenderBinPrototypeList::iterator itr = list-begin(); itr != list-end(); ++itr) { if (itr-second == proto) { list-erase(itr); return; } } } } I've attached the modified file. Christof could you test this and let me know how you get on. If things look fine I'll check the changes into svn/trunk and OSG-2.8 branch. Robert. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * * This library is open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ #include stdlib.h #include string.h #include osgUtil/RenderBin #include osgUtil/RenderStage #include osgUtil/Statistics #include osg/Notify #include osg/ApplicationUsage #include osg/AlphaFunc #include algorithm using namespace osg; using namespace osgUtil; class RenderBinPrototypeList : public osg::Referenced, public std::map std::string, osg::ref_ptrRenderBin { public: RenderBinPrototypeList() {} ~RenderBinPrototypeList() {} }; // register a RenderStage prototype with the RenderBin prototype list. RegisterRenderBinProxy s_registerRenderBinProxy(RenderBin,new RenderBin(RenderBin::getDefaultRenderBinSortMode())); RegisterRenderBinProxy s_registerDepthSortedBinProxy(DepthSortedBin,new RenderBin(RenderBin::SORT_BACK_TO_FRONT)); static RenderBinPrototypeList* renderBinPrototypeList() { static osg::ref_ptrRenderBinPrototypeList s_renderBinPrototypeList = new RenderBinPrototypeList; return s_renderBinPrototypeList.get(); } RenderBin* RenderBin::getRenderBinPrototype(const std::string binName) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list) { RenderBinPrototypeList::iterator itr = list-find(binName); if (itr != list-end()) return itr-second.get(); } return NULL; } RenderBin* RenderBin::createRenderBin(const std::string binName) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list) { RenderBin* prototype = getRenderBinPrototype(binName); if (prototype) return dynamic_castRenderBin*(prototype-clone(osg::CopyOp::DEEP_COPY_ALL)); } osg::notify(osg::WARN) Warning: RenderBin \binName\ implemention not found, using default RenderBin as a fallback.std::endl; return new RenderBin; } void RenderBin::addRenderBinPrototype(const std::string binName,RenderBin* proto) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list proto) { (*list)[binName] = proto; } } void RenderBin::removeRenderBinPrototype(RenderBin* proto) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list proto) { for(RenderBinPrototypeList::iterator itr = list-begin(); itr != list-end(); ++itr) { if (itr-second == proto) { // osg::notify(osg::NOTICE)Found protype, now erasing itr-firststd::endl; list-erase(itr); return; } } } // osg::notify(osg::NOTICE)Not found protypestd::endl; } static bool s_defaultBinSortModeInitialized = false; static RenderBin::SortMode s_defaultBinSortMode = RenderBin::SORT_BY_STATE; static
Re: [osg-users] Bug in RenderBin (?)
Robert Osfield wrote: HI David Christof et. al, On Thu, Mar 12, 2009 at 10:13 AM, David Callu led...@gmail.com wrote: What is smells fishy is the use of proto-className() to identify the renderBin prototype to remove in removeRenderBinPrototype(); Well spotted David, the addRenderBinPrototype() correctly uses binName, while the removeRenderBinProtoype() attempts to use the className() as it's binName. The later is definitely a bug, and one that is easy to fix... Instead, in void RenderBin::removeRenderBinPrototype(RenderBin* proto) we need something like this code void RenderBin::removeRenderBinPrototype(const std::string binName, RenderBin* proto) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list proto) { RenderBinPrototypeList::iterator itr = list-find(binName); if (itr != list-end()) list-erase(itr); } } /code Thought ? There is no need to use the binName, one just needs to search for the pointer in the map by hand, and remove it. But as the RenderBin instances are still stored *by name* in addRenderBinPrototype() doesn't this mean that one of the two instances is lost when the second one is added? Or is that intended? Paul I'm just tested the following code and it looks to be working properly : void RenderBin::removeRenderBinPrototype(RenderBin* proto) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list proto) { for(RenderBinPrototypeList::iterator itr = list-begin(); itr != list-end(); ++itr) { if (itr-second == proto) { list-erase(itr); return; } } } } I've attached the modified file. Christof could you test this and let me know how you get on. If things look fine I'll check the changes into svn/trunk and OSG-2.8 branch. Robert. ___ 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] Bug in RenderBin (?)
Paul Melis wrote: Robert Osfield wrote: HI David Christof et. al, On Thu, Mar 12, 2009 at 10:13 AM, David Callu led...@gmail.com wrote: What is smells fishy is the use of proto-className() to identify the renderBin prototype to remove in removeRenderBinPrototype(); Well spotted David, the addRenderBinPrototype() correctly uses binName, while the removeRenderBinProtoype() attempts to use the className() as it's binName. The later is definitely a bug, and one that is easy to fix... Instead, in void RenderBin::removeRenderBinPrototype(RenderBin* proto) we need something like this code void RenderBin::removeRenderBinPrototype(const std::string binName, RenderBin* proto) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list proto) { RenderBinPrototypeList::iterator itr = list-find(binName); if (itr != list-end()) list-erase(itr); } } /code Thought ? There is no need to use the binName, one just needs to search for the pointer in the map by hand, and remove it. But as the RenderBin instances are still stored *by name* in addRenderBinPrototype() doesn't this mean that one of the two instances is lost when the second one is added? Or is that intended? Oops, never mind, the names are different of course... Paul Paul I'm just tested the following code and it looks to be working properly : void RenderBin::removeRenderBinPrototype(RenderBin* proto) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list proto) { for(RenderBinPrototypeList::iterator itr = list-begin(); itr != list-end(); ++itr) { if (itr-second == proto) { list-erase(itr); return; } } } } I've attached the modified file. Christof could you test this and let me know how you get on. If things look fine I'll check the changes into svn/trunk and OSG-2.8 branch. Robert. ___ 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 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Bug in RenderBin (?)
Hi Robert What about the case of register two prototype with the same name. There are any warning message for the user. I fix this like that void RenderBin::addRenderBinPrototype(const std::string binName, RenderBin* proto) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list proto) { RenderBinPrototypeList::iterator itr = list-find(binName); if (itr != list-end()) osg::notify(osg::WARN) Warning: RenderBinPrototype named \ binName \ already registered std::endl; else (*list)[binName] = proto; } } void RenderBin::removeRenderBinPrototype(const std::string binName, RenderBin* proto) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list proto) { RenderBinPrototypeList::iterator itr = list-find(binName); if (itr != list-end()) { if (itr-second != proto) osg::notify(osg::WARN) Warning: Registered RenderBinPrototype named \ binName \ not match the instance proto std::endl; else list-erase(itr); } } } thought ? David 2009/3/12 Robert Osfield robert.osfi...@gmail.com HI David Christof et. al, On Thu, Mar 12, 2009 at 10:13 AM, David Callu led...@gmail.com wrote: What is smells fishy is the use of proto-className() to identify the renderBin prototype to remove in removeRenderBinPrototype(); Well spotted David, the addRenderBinPrototype() correctly uses binName, while the removeRenderBinProtoype() attempts to use the className() as it's binName. The later is definitely a bug, and one that is easy to fix... Instead, in void RenderBin::removeRenderBinPrototype(RenderBin* proto) we need something like this code void RenderBin::removeRenderBinPrototype(const std::string binName, RenderBin* proto) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list proto) { RenderBinPrototypeList::iterator itr = list-find(binName); if (itr != list-end()) list-erase(itr); } } /code Thought ? There is no need to use the binName, one just needs to search for the pointer in the map by hand, and remove it. I'm just tested the following code and it looks to be working properly : void RenderBin::removeRenderBinPrototype(RenderBin* proto) { RenderBinPrototypeList* list = renderBinPrototypeList(); if (list proto) { for(RenderBinPrototypeList::iterator itr = list-begin(); itr != list-end(); ++itr) { if (itr-second == proto) { list-erase(itr); return; } } } } I've attached the modified file. Christof could you test this and let me know how you get on. If things look fine I'll check the changes into svn/trunk and OSG-2.8 branch. Robert. ___ 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] Bug in RenderBin (?)
I'm using the current 2.8.0 stable release. I used the 'Browse Source' to check the current trunk version of RenderBin.cpp and I see no change since. The actual crash occurs later in static object destruction when s_renderBinPrototypeList is destructed itself. I don't understand enough of osg to know what's exactly wrong. However, the s_registerDepthSortedBinProxy doesn't release the object it created and this looks very suspicious to me. I hadn't had this issue when using the non-static build with VS80, so this might be a trigger. However, due to various reasons, I prefer static builds without DLLs for my current project. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=8317#8317 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Bug in RenderBin (?)
Hi David, On Thu, Mar 12, 2009 at 10:46 AM, David Callu led...@gmail.com wrote: What about the case of register two prototype with the same name. There are any warning message for the user. I fix this like that There is only ever supposed to be one prototype per binName, and the std::mapbinname,prototype ensures this is the case. If you attach two different bins under the same binName then the first will be replaced by the second one and the first one will automatically be unref'd. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Bug in RenderBin (?)
On Thu, Mar 12, 2009 at 11:20 AM, Paul Melis p...@science.uva.nl wrote: What was the use case for the bin names again? I mean, as there are already bin numbers that uniquely identify a bin are the names merely descriptive? The bin number controls the high level ordering, but the RenderBin itself provides the control of the sorting and traversal - so the fine grained ordering. The scene graph's StateSet::RenderBin details contains the bin number and renderbin prototype name that is used to decide how which RenderBin prototype to go clone for the rendering backend to implement what the scene graph requests. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Bug in RenderBin (?)
Robert Osfield wrote: Hi David, On Thu, Mar 12, 2009 at 10:46 AM, David Callu led...@gmail.com wrote: What about the case of register two prototype with the same name. There are any warning message for the user. I fix this like that There is only ever supposed to be one prototype per binName, and the std::mapbinname,prototype ensures this is the case. If you attach two different bins under the same binName then the first will be replaced by the second one and the first one will automatically be unref'd. What was the use case for the bin names again? I mean, as there are already bin numbers that uniquely identify a bin are the names merely descriptive? Regards, Paul ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Bug in RenderBin (?)
I'll be able to test it tomorrow and will inform you about the outcome. Thanks for your help so far! I'd be very surprised if this didn't fix it. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=8405#8405 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Bug in RenderBin (?)
Hi, I'm new to OpenSceneGraph and not sure if I get everything right. I get crashes with Visual Studio 2005 static build after the main function returns. The crash occurs while the static s_renderBinPrototypeList is destructed. While debugging, I have found something suspicious: There are two RegisterRenderBinProxy instances in RenderBin.cpp, one with the name RenderBin and one with DepthSortedBin. They both add the corresponding entries to the s_renderBinPrototypeList correctly before main() enters. However, the s_registerDepthSortedBinProxy removes the wrong entry in s_renderBinPrototypeList afterwards. This happens because the proxy class calls removeRenderBinPrototype which uses proto-className to find the entry to erase from the s_renderBinPrototypeList map. Remember that the destructor of s_registerDepthSortedBinProxy should remove the DepthSortedBin entry. Unfortunately, proto-className equals RenderBin in both cases. When s_registerRenderBinProxy tries to delete the RenderBin entry later, it fails because it is already deleted. Then, s_renderBinPrototypeList still contains the DepthSortedBin entry which was never deleted. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=8293#8293 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org