OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

osgTerrain destruction problem

Goto page 1, 2  Next
 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> VirtualPlanetBuilder [vpb]
View previous topic :: View next topic  
Author Message
pablocael
Newbie


Joined: 03 May 2011
Posts: 15

PostPosted: Thu Nov 28, 2013 3:26 pm    Post subject:
osgTerrain destruction problem
Reply with quote

Hi all,

our team is currently facing a strage problem when deleting a osgTerrain instance loaded from a geotiff heightmap. When we delete an instance of osgTerrain, is damages the Qt OpenGL state. All widgets rendered within opengl canvas (by QPainter) gets crazy (totally non functional, qt starts rendering garbage). But when we recreate the terrain right after deleting it, the Qt state get restored (in that case the SO give us the same memory are by pure luck, since a shorte period of time has passed and the old memory are is still available).

One theory is that some point of Qt memory and osgTerrain memory is somehow being shared (due to an memory invasion or some other reason). When osgTerrain deletes its contents and tiles, it affects somehow other parts of program memory.

I´ve read some issues with osgTerrain tile destruction, but I have never seen any patches to fix them. So, I thing that this maybe related to the same issues.. (possibly)...

Does any one know if there is any really known issue with osgTerrain destructor and/or whether there is any solution to it? Even a temporay one..

Robert once said that using DatabasePager::setDeleteRemovedSubgraphsInDatabaseThread(false)
should suppress a double delete problem. But I could find how to apply this line of code since I couldnt find DatabasePager instance....

Our app get in trouble when we delete osgTerrain instances and we really need that! Thank you in advance!

Thanks!!
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10859

PostPosted: Thu Nov 28, 2013 3:31 pm    Post subject:
osgTerrain destruction problem
Reply with quote

Hi Pablo,

I am not aware of any current delete issues.  


The big question that pops up with your usage case is just exactly are you deleting the osgTerrain objects?  


You never delete nodes directly, simply unrefering them and let ref counting handling do the clean up as required.


Robert.



On 28 November 2013 15:26, Pablo Carneiro Elias < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi all,

our team is currently facing a strage problem when deleting a osgTerrain instance loaded from a geotiff heightmap. When we delete an instance of osgTerrain, is damages the Qt OpenGL state. All widgets rendered within opengl canvas (by QPainter) gets crazy (totally non functional, qt starts rendering garbage). But when we recreate the terrain right after deleting it, the Qt state get restored (in that case the SO give us the same memory are by pure luck, since a shorte period of time has passed and the old memory are is still available).

One theory is that some point of Qt memory and osgTerrain memory is somehow being shared (due to an memory invasion or some other reason). When osgTerrain deletes its contents and tiles, it affects somehow other parts of program memory.

I´ve read some issues with osgTerrain tile destruction, but I have never seen any patches to fix them. So, I thing that this maybe related to the same issues.. (possibly)...

Does any one know if there is any really known issue with osgTerrain destructor and/or whether there is any solution to it? Even a temporay one..

Robert once said that using DatabasePager::setDeleteRemovedSubgraphsInDatabaseThread(false)
should suppress a double delete problem. But I could find how to apply this line of code since I couldnt find DatabasePager instance....

Our app get in trouble when we delete osgTerrain instances and we really need that! Thank you in advance!

Thanks!!

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





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
pablocael
Newbie


Joined: 03 May 2011
Posts: 15

PostPosted: Thu Nov 28, 2013 3:37 pm    Post subject:
Reply with quote

Hi Robert,

well, I am sure I am not deleting the node. We have a osg::ref_ptr<osg::Node> pointer to the osgTerrain instance. And by 'delete' the terrain I actually mean setting the smart pointer to zero.

Pablo
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10859

PostPosted: Thu Nov 28, 2013 3:51 pm    Post subject:
osgTerrain destruction problem
Reply with quote

HI Pablo,

On 28 November 2013 15:37, Pablo Carneiro Elias < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
well, I am sure I am not deleting the node. We have a osg::ref_ptr<osg::Node> pointer to the osgTerrain instance. And by 'delete' the terrain I actually mean setting the smart pointer to zero.


OK, so you are unrefering the node.  In what context is this unrefereing?  Is the node not part of the scene graph that is attached to the viewer?  Are you holding a reference to it in your application?


Normally when you are using a paged database you never need to keep references around to the nodes in the scene graph, instead you just let the DatabasePager expire subgraphs as required.


As for the DatabasePager instance, the osgViewer::View class has a getDatabasePager() method, so just do viewer.getDatabasePager() or view.getDatabasePager().  I just takes a quick search of the headers to find this method.


Robert.
 

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
pablocael
Newbie


Joined: 03 May 2011
Posts: 15

PostPosted: Thu Nov 28, 2013 4:31 pm    Post subject:
Reply with quote

Thanks Robert,

I´ve tried the databasepage setting.. no success.. Its a very strange problem.... Its deterministic: the destruction of terrain messes up the QPainter state. I am rendering FPS and some other infos using QPainter within QGLWidget as PaintDevice. The destruction of the terrain makes QPainter draw garbage and sometimes not render anything! Very strange. If I then create the terrain again, every thing backs to normal (!!).. I am using QGLWidget as opengl context holder and osgViewer::GraphicsWindowEmbedded to create a contextless window. So QT has the opengl context. The strange thing is that all other models in the scene keep being rendered fine (so its not opengl state problem I guess). I also tried to put glPushAttrib(GL_ALL_ATTRIBS_BIT)/glPopAttrib before/after QPainter calls and also cleaning up ogl matrices... nothing yield any results...

I don´t know if you can give me any clue about any possible theoretical problem that may be hapening here...

Thanks again.

Pablo
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10859

PostPosted: Thu Nov 28, 2013 5:05 pm    Post subject:
osgTerrain destruction problem
Reply with quote

Hi Pablo,

It sounds like an issue with OpenGL state management.  Personally I'd avoid using Qt for any OpenGL work and keep OpenGL the domain of the OSG's graphics context.  I'd also use of GrpahicsWindowEmbedded for anything other than very limited use applications.


The OSG has pretty decent text support and plenty of OSG example that illustrate how to do text on a hud for things like FPS etc, there really should be little need for using Qt for this.  See the osghud example for inspiration.


Robert.



On 28 November 2013 16:31, Pablo Carneiro Elias < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Thanks Robert,

I´ve tried the databasepage setting.. no success.. Its a very strange problem.... Its deterministic: the destruction of terrain messes up the QPainter state. I am rendering FPS and some other infos using QPainter within QGLWidget as PaintDevice. The destruction of the terrain makes QPainter draw garbage and sometimes not render anything! Very strange. If I then create the terrain again, every thing backs to normal (!!).. I am using QGLWidget as opengl context holder and osgViewer::GraphicsWindowEmbedded to create a contextless window. So QT has the opengl context. The strange thing is that all other models in the scene keep being rendered fine (so its not opengl state problem I guess). I also tried to put glPushAttrib(GL_ALL_ATTRIBS_BIT)/glPopAttrib before/after QPainter calls and also cleaning up ogl matrices... nothing yield any results...

I don´t know if you can give me any clue about any possible theoretical problem that may be hapening here...

Thanks again.

Pablo

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=57478#57478





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
pablocael
Newbie


Joined: 03 May 2011
Posts: 15

PostPosted: Thu Nov 28, 2013 8:09 pm    Post subject:
Reply with quote

Hi Robert, I could find where the problem occurs inside Qt using gDebugger..

I know OSG has hud systems, but unfortunately we are rendering very complex elements and QPainter api is very good at rendering complex things.. It has lots of draw methods for many things...

So, the call stack of the error is that:

QGL2PaintEngineExPrivate::drawCachedGlyphs - qpaintengineex_opengl2.cpp, line 1761

QGL2PaintEngineEx::drawTextItem - qpaintengineex_opengl2.cpp, line 1478
QPainter::drawTextItem - qpainter.cpp, line 6545
QPainter::drawText - qpainter.cpp, line 6030
QPainter::drawText - qpainter.cpp, line 5820
QPainter::drawText - qpainter.h, line 957
sea::blocks::render::GLCanvas::paintGL - block.cpp, line 278
QGLWidget::glDraw - qgl.cpp, line 4483
QGLWidget::updateGL - qgl.cpp, line 4029

the line 1761 is a call do glDrawElements: qt is trying to use drawelements to draw qpainter stuff... which suggests that maybe some vbo index that Qt is trying to use is invalid. I have now a theory.. For some reason, when the terrain is destroyed, the Qt vbo is being destroyed by the terrain.

I dont know how it might happen, its just a theory, but it would explain a lot:

- First of all, when the terrain is destroyed , the qt vbo gets destroyed and qt starts rendering an invalid vbo which produces strange geometry, what explains the strange things in screen rendered by qpainter

- Secondly, when the terrain is created once again, the vbo is then recreated (since the vbo index is now free, opengl recreates it). Since the vbo in now valid again, qt is able to render properly again..

This theory explains very well the problem I am facing here. The only problem is that I habe no clue if there is really a problem in vbo management within osgTerrain... Do you know any source or part of code that might be causing something like this? If you point me anything I can debug my self using osg project here..

What do you think?

Thanks
Back to top
View user's profile Send private message
pablocael
Newbie


Joined: 03 May 2011
Posts: 15

PostPosted: Fri Nov 29, 2013 12:04 pm    Post subject:
Reply with quote

Hi Robert,

I think I confirm the problem. I´ve created a visitor that disables VBO in all geodes of the terrain, right after loading it. Without vbo, everything works perfectly.. no bug in qt qpainter rendering! I am able to destroy the terrain without any issues!

So, its possible that osg terrain has some issue with vbo management. I dont know if the osg philosophy is to take over the ogl context, but in my opinion, if it is really some vbo management issue, I think it would be good for osg to cooperate with other subsystems using ogl context properly, since there are many complementary libraries that can be used with osg using the same context.


Thanks Robert!

Pablo
Back to top
View user's profile Send private message
webmaster
Guest





PostPosted: Fri Nov 29, 2013 12:28 pm    Post subject:
osgTerrain destruction problem
Reply with quote

hi Pablo,
You can modify the osg code in VBO detection stage,this is a efficient method,and no need write any code,only comment two line OSG code,then all is OK!
Regards
zhuwan
11,29,2013
Quote:
> -----原始邮件-----
Quote:
发件人: "Pablo Carneiro Elias" <>
发送时间: 2013-11-29 20:04:40
收件人:
抄送:
主题: Re: [vpb] osgTerrain destruction problem

Hi Robert,

I think I confirm the problem. I´ve created a visitor that disable VBO in all geodes of the terrain, right after loading it. Without vbo, everything works perfectly.. not bug in qt! I am able to destroy the terrain without any issues!

So, its possible that osg terrain has some issue with vbo management. I dont know if the osg philosophy is to take over the ogl context, but in my opinion, if it is really some vbo management issue, I think it would be good for osg to cooperate with other subsystems using ogl context properly, since there are many complementary libraries that can be used with osg using the same context.


Thanks Robert!

Pablo

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








------------------
Post generated by Mail2Forum
Back to top
pablocael
Newbie


Joined: 03 May 2011
Posts: 15

PostPosted: Fri Nov 29, 2013 12:43 pm    Post subject:
Reply with quote

Thanks webmaster,

can you point me some directions in osg project, a subproject or a file where this two lines are located?

Thanks

Pablo
Back to top
View user's profile Send private message
pablocael
Newbie


Joined: 03 May 2011
Posts: 15

PostPosted: Fri Nov 29, 2013 12:49 pm    Post subject:
Reply with quote

I think I found.. osg/State.cpp line 1238.

Is that right?
Thanks.
Back to top
View user's profile Send private message
webmaster
Guest





PostPosted: Fri Nov 29, 2013 1:10 pm    Post subject:
osgTerrain destruction problem
Reply with quote

Hi Pablo,
Seems the newest OSG svn code have changed some,currently you can try to let following code always return false,I haven't tried this new method,but think it is work correctly also:
bool State::computeVertexBufferObjectSupported() const
{
_isVertexBufferObjectSupportResolved = true;
_isVertexBufferObjectSupported = OSG_GLES2_FEATURES || OSG_GL3_FEATURES || osg::isGLExtensionSupported(_contextID,"GL_ARB_vertex_buffer_object");
return _isVertexBufferObjectSupported;
}
cheers
zhuwan
11,29,2013

Quote:
> -----原始邮件-----
Quote:
发件人: "Pablo Carneiro Elias" <>
发送时间: 2013-11-29 20:49:09
收件人:
抄送:
主题: Re: [vpb] osgTerrain destruction problem

I think I found.. osg/State.cpp line 1238.

Is that right?
Thanks.

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








------------------
Post generated by Mail2Forum
Back to top
pablocael
Newbie


Joined: 03 May 2011
Posts: 15

PostPosted: Fri Nov 29, 2013 1:42 pm    Post subject:
Reply with quote

Thanks!

That's the same code chunk I found ;]

Pablo
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 10859

PostPosted: Fri Nov 29, 2013 2:04 pm    Post subject:
osgTerrain destruction problem
Reply with quote

HI Pablo,
There isn't a bug in the OSG that you need to chase after, the bug is in the integration in your application between Qt + OSG.  If there is an issue with VBO usage on the OSG side there there is clearly state leakage from the OSG side to the Qt that your glue layer will need to deal with.  This state leakage is purely state being set to on or OFF by the OSG and not being reset, while the Qt GL code assumes that particular state is set to something but it's not so the bug come about.


If you want to go ahead an integrate against advice then fine but you'll need to learn more about OpenGL state and what is being set by the OSG and Qt.  


Robert.

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
pablocael
Newbie


Joined: 03 May 2011
Posts: 15

PostPosted: Fri Nov 29, 2013 3:55 pm    Post subject:
Reply with quote

Thanks Robert,

I understand that it may be a problem of "assumed state". And judging by the issue, it is related to VBO state (client state).

So I have tried to place this before osg frame() method:

glPushAttrib( GL_ALL_ATTRIBS_BIT );
glPushClientAttrib( GL_CLIENT_ALL_ATTRIB_BITS );

glEnableClientState( GL_VERTEX_ARRAY );

frame();

glPopClientAttrib();
glPopAttrib();

It worked, but the terrain got very strange (dont understand why.. it got tiled with low resolution... )

It seems just strange to me the solution "do not use two ogl systems at once, only one or another...", since ogl is created as a global shared context in fact to allow such easy integration... . But in the end I think I will be able to make some working integration here... ;/


Thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> VirtualPlanetBuilder [vpb] All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts osgFX::Outline Redraw Problem sshaw General 3 Tue Apr 25, 2017 6:51 pm View latest post
No new posts Scale problem while transforming obje... YuraIU02 General 1 Sat Apr 15, 2017 4:26 pm View latest post
No new posts OSG 3.4 and Qt 5 cmake problem. Found... Elias Tarasov General 1 Mon Apr 10, 2017 12:26 pm View latest post
No new posts osg::Image::setImage problem evanyftsai General 6 Sat Feb 18, 2017 2:38 am View latest post
No new posts problem with shapefile height when lo... vinothrajendran4 General 2 Thu Feb 16, 2017 12:22 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP