Re: [osg-users] DBPager continuously reloading tiles
Robert, Here's a simple viewer I wrote that does non-continuous render and exhibits the problem. You can just run it like the osgviewer application, passing in the path to a database on the command line. I have also included a stats handler that will cause the app to switch to continuous render while it is onscreen. I have only tested this with osgEarth, so I don't know if the problem manifests itself with VPB databases. The reloading problem wouldn't manifest itself when I ran an animation path because playing back the animation essentially caused continuous rendering, but if you load an earth database and move around a bit in the scene you should see the behavior. I can get it to happen pretty reliably when I load the yahoo satellite images using osgEarth, then quickly zoom in on an area that I have cached. When I stop zooming and zoom back out or pan around, the tiles start reloading. I had a co-worker try this out and he was able to duplicate the problem pretty quickly, so hopefully it will happen easily for you too. Evan On Thu, Apr 23, 2009 at 2:14 AM, Robert Osfield robert.osfi...@gmail.comwrote: Hi Evan, On Wed, Apr 22, 2009 at 10:05 PM, Evan Andersen andersen.e...@gmail.com wrote: Ryan, Thank you for the suggestion. When I call setTargetMaximumNumberOfPagedLOD(0) on the database pager, as you suggested and then set the expiry delay to DBL_MAX and the expiry frames to 10, as Jason Suggested the problem seems to go away. I'm not really sure why this works. It seems like the default behavior should work in my usage case, but at least it is working now. Could you modify one of the OSG examples to reproduce your application usage style and use this to recreate the problem. I could then have a look at why the new (and now default) expiry scheme is not working correctly. As you say it should work, at present I don't know why the old scheme is able to work. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org #include osgViewer/viewer #include osgDB/ReadFile #include osgViewer/ViewerEventHandlers #include osgGA/TrackballManipulator #include osgGA/FlightManipulator #include osgGA/DriveManipulator #include osgGA/KeySwitchMatrixManipulator #include osgGA/StateSetManipulator #include osgGA/TerrainManipulator #include OpenThreads/Thread #include cfloat // The stats handler has to be modified to request continuous updates // when stats are being displayed class MyStats : public osgViewer::StatsHandler { protected: ~MyStats() {} int keyPresses; public: MyStats() : osgViewer::StatsHandler(), keyPresses(0) {} virtual bool handle(const osgGA::GUIEventAdapter ea, osgGA::GUIActionAdapter aa) { if( ea.getEventType() != osgGA::GUIEventAdapter::KEYDOWN ) return false; int key = ea.getKey(); if(key == -1) return false; if(key == 's') { if(keyPresses 4) { aa.requestContinuousUpdate(true); keyPresses++; } else { keyPresses = 0; aa.requestContinuousUpdate(false); aa.requestRedraw(); } return osgViewer::StatsHandler::handle(ea, aa); } return false; } }; class MyViewer : public osgViewer::Viewer { public: MyViewer() : osgViewer::Viewer(), needsRender(true), continuousUpdate(false) {} MyViewer(osg::ArgumentParser arguments) : osgViewer::Viewer(arguments), needsRender(true), continuousUpdate(false) {} virtual void requestRedraw() { needsRender = true; } virtual void requestContinuousUpdate(bool needed=true) { continuousUpdate = needed; } virtual int run() { // From osgViewer::Viewer if (!getCameraManipulator() getCamera()-getAllowEventFocus()) { setCameraManipulator(new osgGA::TrackballManipulator); } setReleaseContextAtEndOfFrameHint(false); // From osgViewer::ViewerBase if (!isRealized()) { realize(); } /***/ // This block of code seems to fix the reloading problems //getDatabasePager()-setTargetMaximumNumberOfPageLOD(0); //getDatabasePager()-setExpiryDelay(DBL_MAX); //getDatabasePager()-setExpiryFrames(10); /**/ while (!done()) { frame(); // Sleep for 10 miliseconds. This is just an arbitrary value, but we'd // do something intelligent to make the loop run at a desired rate. OpenThreads::Thread::microSleep(1); } return 0; } virtual void frame(double simulationTime
Re: [osg-users] DBPager continuously reloading tiles
Robert, Things seem to work fine if I only call advance() when a render is done. Off the top of your head, can you think of any problems that might be caused by not doing an advance for every iteration of the event and update traversals? Would it be better to advance the reference time at each iteration and only advance the frame number when a render is performed? Also in regards to the potential problems with pre-compiling objects, I assume that I can just call requiresCompileGLObjects on the pager in each iteration of the main loop and then do a render if it returns true. My main concern is doing unnecessary renders while the pager is downloading tiles from an internet source. Thanks for all your help. Evan On Thu, Apr 23, 2009 at 10:16 AM, Robert Osfield robert.osfi...@gmail.comwrote: On Thu, Apr 23, 2009 at 4:32 PM, Robert Osfield robert.osfi...@gmail.com wrote: Thanks Evan, with your example I'm able to see the problem when browsing http://www.openscenegraph.org/data/earth_bayarea/earth.ive. I'll now dig into the DatabasePager to see what is up. The culprit looks to be the following (normally valid) code in DatabasePager::capped_removeExpiredSubgraphs(const osg::FrameStamp frameStamp): int delta = frameStamp.getFrameNumber() - plod-getFrameNumberOfLastTraversal(); if (delta1) { if (_releaseDelay!=DBL_MAX) { plod-releaseGLObjects(); osg::notify(osg::NOTICE)DatabasePager::removeExpiredSubgraphs(), releasing gl objectsstd::endl; } _inactivePagedLODList.push_back(plod); itr = _activePagedLODList.erase(itr); } The only reason why this is a problem in this particular usage case is that you have a viewer that is continue to increment the frame count so the frameStamp.getFrameNumber() keeps getting incremented, but since the scene isn't being rendering the plod-getFrameNumberOfLastTraversal() is not updating so the frame delta becomes 1 and the PagedLOD gets assigned as expired. The code in DatabasePager is correct for how the pager + PagedLOD were designed to be used. The problem is that code is now being used in way that is wasn't originally intended. Updating the frame count and not rendering is the problem. Not updating the frame count and not rendering would work, as does updating the frame count and rendering. The next question is how to either get the viewer or DatabasePager to do what is desired here - i.e. lazy updating of the graphics. It might be possible to tell the DatabasePager that rendering of frame is switched off for that frame and for it handle this case. Tweaking the application code so that it doesn't do an viewer.advance() until a new frame is actually required. It's also worth noting that there is a potential bug in the supplied viewer that does lazy update - it only will ever work if the pager isn't doing precompile, if it does do precompile then you have to render frames to enable the pager to get it's GL objects compiled, otherwise the pager will just go to sleep waiting for the objects to be compiled by the rendering thread(s), then you'd have stale mate. A possible way to solve this would be to check the DatabasePager to see if it has any database requests that are still active, and keeping rendering while it does. 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] DBPager continuously reloading tiles
Ryan, Thank you for the suggestion. When I call setTargetMaximumNumberOfPagedLOD(0) on the database pager, as you suggested and then set the expiry delay to DBL_MAX and the expiry frames to 10, as Jason Suggested the problem seems to go away. I'm not really sure why this works. It seems like the default behavior should work in my usage case, but at least it is working now. -Evan On Tue, Apr 21, 2009 at 9:25 AM, Kawicki, Ryan H ryan.h.kawi...@boeing.comwrote: As in your case, we also have high resolution insets which exhibit this problem, but our applications are centered around a continuous render update. Robert can correct me if I am wrong, but the new mechanism for controlling how nodes are paged in and out of memory is defaulted to ( I think ) 300 for the target maximum number of page lods. Because this value is set, removing of expired subgraphs will go down the path of removing capped paged lods instead of the expiry. To use the expiry system of old, make sure to call setTargetMaximumNumberOfPageLOD(0) on the database pager, and the expiry values you have set should kick in. We have tried increasing the target maximum, but we run a greater risk of consuming too much memory for a 32 bit application on Windows. Because of time restraints, I have not been able to follow-up on this problem. Sorry. *Ryan H. Kawicki* The Boeing Company Training Systems Services Software Engineer -- *From:* Evan Andersen [mailto:andersen.e...@gmail.com] *Sent:* Monday, April 13, 2009 10:08 AM *To:* OpenSceneGraph Users *Subject:* Re: [osg-users] DBPager continuously reloading tiles I tried the settings you suggested Jason, but I still get the same behavior. -Evan On Fri, Apr 10, 2009 at 5:57 PM, Jason Beverage jasonbever...@gmail.comwrote: Hi Evan, What happens if you set the expiry frame to something like 10 and the expiry time to DBL_MAX? I haven't tried running the DatabasePager without non-continuous rendering, so I'm not sure how well it works. Jason On Fri, Apr 10, 2009 at 5:20 PM, Evan Andersen andersen.e...@gmail.comwrote: Thanks for your response Robert. I just tried setting the expiry delay of the database pager to 10, 100, and 1000, but still have the same problem. I also tried increasing the expiry frames count to 60, but that didn't help either. -Evan On Fri, Apr 10, 2009 at 2:33 PM, Robert Osfield robert.osfi...@gmail.com wrote: On Fri, Apr 10, 2009 at 6:43 PM, Evan Andersen andersen.e...@gmail.com wrote: Sorry, I forgot to mention that. I'm using version 2.9.2 from the trunk. Thanks for the clarification. Changes in DatabasePager in 2.8 onwards should make it easier to do what you are doing. The DatabasePager and PagedLOD were still designed around continuous rendering though so you are running a bit off usual usage model so might need to tweak a few things. My guess is that the PageLOD are expiring their children as they haven't been traversed for a given amount of time. You can adjust the expiry delay via the DatabaePager API so have a browse. 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 ___ 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] DBPager continuously reloading tiles
I tried the settings you suggested Jason, but I still get the same behavior. -Evan On Fri, Apr 10, 2009 at 5:57 PM, Jason Beverage jasonbever...@gmail.comwrote: Hi Evan, What happens if you set the expiry frame to something like 10 and the expiry time to DBL_MAX? I haven't tried running the DatabasePager without non-continuous rendering, so I'm not sure how well it works. Jason On Fri, Apr 10, 2009 at 5:20 PM, Evan Andersen andersen.e...@gmail.comwrote: Thanks for your response Robert. I just tried setting the expiry delay of the database pager to 10, 100, and 1000, but still have the same problem. I also tried increasing the expiry frames count to 60, but that didn't help either. -Evan On Fri, Apr 10, 2009 at 2:33 PM, Robert Osfield robert.osfi...@gmail.com wrote: On Fri, Apr 10, 2009 at 6:43 PM, Evan Andersen andersen.e...@gmail.comwrote: Sorry, I forgot to mention that. I'm using version 2.9.2 from the trunk. Thanks for the clarification. Changes in DatabasePager in 2.8 onwards should make it easier to do what you are doing. The DatabasePager and PagedLOD were still designed around continuous rendering though so you are running a bit off usual usage model so might need to tweak a few things. My guess is that the PageLOD are expiring their children as they haven't been traversed for a given amount of time. You can adjust the expiry delay via the DatabaePager API so have a browse. 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 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] DBPager continuously reloading tiles
I'm working on an application which uses osgEarth to display terrain databases to users. I need the application to use as little CPU time as possible while still providing good user interaction, so I have set my viewer up so that it only renders when necessary. I keep a loop running that does the event and update traversals, but the renderingTraversals are only done when requestRedraw or requestContinuousUpdate have been called. This seems to work fine and to the user it generally beahves the same as when the scene is continuously rendered. However, when viewing the high detail levels it database pager often gets stuck in a loop when it keeps reloading a set of tiles over and over. You see the tiles alternately go blurry and then sharp again as the continously reload. I don't know what is causing this, but if I switch to continuous render, so that every event and update traversal is followed by a render, the problem does not occur. It seems to happen most often loading earth files with high-res data, like the yahoo or google test files, and then moving the camera around at the high detail levels. Unfortunately, I can't seem to replicate the problem with an animation path. I have attached a simple viewer I created that implements the rendering method I described above. The important code is in the viewer's frame function. I've pasted it below in case anyone can tell at a glance what I'm doing wrong. If someone who knows the database pager well could take a look at this I would really appreciate it. Thanks, Evan advance(simulationTime); eventTraversal(); // If the database pager is going to update the scene the render flag is // set so that the updates show up if(getDatabasePager()-requiresUpdateSceneGraph()) needsRender = true; updateTraversal(); if(needsRender || continuousUpdate) { renderingTraversals(); needsRender = false; } // RenderOnDemand.cpp : Defines the entry point for the console application. // #include osgViewer/viewer #include osgDB/ReadFile #include osgViewer/ViewerEventHandlers #include osgGA/TrackballManipulator #include osgGA/FlightManipulator #include osgGA/DriveManipulator #include osgGA/KeySwitchMatrixManipulator #include osgGA/StateSetManipulator #include osgGA/TerrainManipulator #include OpenThreads/Thread // The stats handler has to be modified to request continuous updates // when stats are being displayed class MyStats : public osgViewer::StatsHandler { protected: ~MyStats() {} int keyPresses; public: MyStats() : osgViewer::StatsHandler(), keyPresses(0) {} virtual bool handle(const osgGA::GUIEventAdapter ea, osgGA::GUIActionAdapter aa) { if( ea.getEventType() != osgGA::GUIEventAdapter::KEYDOWN ) return false; int key = ea.getKey(); if(key == -1) return false; if(key == 's') { if(keyPresses 4) { aa.requestContinuousUpdate(true); keyPresses++; } else { keyPresses = 0; aa.requestContinuousUpdate(false); aa.requestRedraw(); } return osgViewer::StatsHandler::handle(ea, aa); } return false; } }; class MyViewer : public osgViewer::Viewer { public: MyViewer() : osgViewer::Viewer(), needsRender(true), continuousUpdate(false) {} MyViewer(osg::ArgumentParser arguments) : osgViewer::Viewer(arguments), needsRender(true), continuousUpdate(false) {} virtual void requestRedraw() { needsRender = true; } virtual void requestContinuousUpdate(bool needed=true) { continuousUpdate = needed; } virtual int run() { // From osgViewer::Viewer if (!getCameraManipulator() getCamera()-getAllowEventFocus()) { setCameraManipulator(new osgGA::TrackballManipulator); } addEventHandler(new MyStats()); setReleaseContextAtEndOfFrameHint(false); // From osgViewer::ViewerBase if (!isRealized()) { realize(); } while (!done()) { frame(); //Sleep for 10 miliseconds OpenThreads::Thread::microSleep(1); } return 0; } virtual void frame(double simulationTime=USE_REFERENCE_TIME) { if (_done) return; // osg::notify(osg::NOTICE)std::endlCompositeViewer::frame()std::endlstd::endl; if (_firstFrame) { viewerInit(); if (!isRealized()) { realize(); } _firstFrame = false; } advance(simulationTime); eventTraversal(); // If the database pager is going to update the scene the render flag is // set so that the updates show up
Re: [osg-users] DBPager continuously reloading tiles
Sorry, I forgot to mention that. I'm using version 2.9.2 from the trunk. -Evan On Fri, Apr 10, 2009 at 11:28 AM, Robert Osfield robert.osfi...@gmail.comwrote: Hi Evan, Which version of the OSG are you using? Robert. On Fri, Apr 10, 2009 at 6:07 PM, Evan Andersen andersen.e...@gmail.comwrote: I'm working on an application which uses osgEarth to display terrain databases to users. I need the application to use as little CPU time as possible while still providing good user interaction, so I have set my viewer up so that it only renders when necessary. I keep a loop running that does the event and update traversals, but the renderingTraversals are only done when requestRedraw or requestContinuousUpdate have been called. This seems to work fine and to the user it generally beahves the same as when the scene is continuously rendered. However, when viewing the high detail levels it database pager often gets stuck in a loop when it keeps reloading a set of tiles over and over. You see the tiles alternately go blurry and then sharp again as the continously reload. I don't know what is causing this, but if I switch to continuous render, so that every event and update traversal is followed by a render, the problem does not occur. It seems to happen most often loading earth files with high-res data, like the yahoo or google test files, and then moving the camera around at the high detail levels. Unfortunately, I can't seem to replicate the problem with an animation path. I have attached a simple viewer I created that implements the rendering method I described above. The important code is in the viewer's frame function. I've pasted it below in case anyone can tell at a glance what I'm doing wrong. If someone who knows the database pager well could take a look at this I would really appreciate it. Thanks, Evan advance(simulationTime); eventTraversal(); // If the database pager is going to update the scene the render flag is // set so that the updates show up if(getDatabasePager()-requiresUpdateSceneGraph()) needsRender = true; updateTraversal(); if(needsRender || continuousUpdate) { renderingTraversals(); needsRender = false; } ___ 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