time elapsed exception

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
machineonpointer
Kobold
Posts: 35
Joined: Fri Dec 06, 2013 4:15 am

time elapsed exception

Post by machineonpointer »

A class implemented the Ogre::WindowEventListener

Code: Select all

frameRenderingQueued(const Ogre::FrameEvent& evt)
{
...
}
sometimes the evt.timeSinceLastFrame became very large, here is the log of several frames.
08-07 22:59:01.636: I/OGRE(13777): time elapsed:: x:0.022
08-07 22:59:01.666: I/OGRE(13777): time elapsed:: x:0.025
08-07 22:59:01.696: I/OGRE(13777): time elapsed:: x:0.026
08-07 22:59:01.157: I/OGRE(13777): time elapsed:: x:4.29497e+06
08-07 22:59:01.167: I/OGRE(13777): time elapsed:: x:0.113
08-07 22:59:01.187: I/OGRE(13777): time elapsed:: x:0.023
08-07 22:59:01.217: I/OGRE(13777): time elapsed:: x:0.021

4.29497e+06 is an obvious exception, has anyone met with this ? Don't know if it's a misuse or a bug of the engine.
User avatar
tod
Troll
Posts: 1394
Joined: Wed Aug 02, 2006 9:41 am
Location: Bucharest
x 94
Contact:

Re: time elapsed exception

Post by tod »

That is obviously strange and shouldn't happen if you use the default rendering methods.
machineonpointer
Kobold
Posts: 35
Joined: Fri Dec 06, 2013 4:15 am

Re: time elapsed exception

Post by machineonpointer »

tod wrote:That is obviously strange and shouldn't happen if you use the default rendering methods.
Sorry, what do you mean "default rendering methods"? The rendering method logic:

Code: Select all

       static void step()
        {
            if (mRenderWnd != NULL && mRenderWnd->isActive ())
            {
                mRenderWnd->windowMovedOrResized ();
                mRoot->renderOneFrame ();
            }
        }
The step() function is called continuously.
Yes the time interval at the exception point is too long(4.29497e+06 seconds, a fault), I did not change the value of evt.
User avatar
tod
Troll
Posts: 1394
Joined: Wed Aug 02, 2006 9:41 am
Location: Bucharest
x 94
Contact:

Re: time elapsed exception

Post by tod »

Yeah, that's the default way that should work correctly.
Do you run in debug mode? If not try debug mode and see if you get the same error. If you only get it in release it is probably some overflow.
machineonpointer
Kobold
Posts: 35
Joined: Fri Dec 06, 2013 4:15 am

Re: time elapsed exception

Post by machineonpointer »

tod wrote:Yeah, that's the default way that should work correctly.
Do you run in debug mode? If not try debug mode and see if you get the same error. If you only get it in release it is probably some overflow.
Yes, It happens both in debug mode and release mode.
User avatar
tod
Troll
Posts: 1394
Joined: Wed Aug 02, 2006 9:41 am
Location: Bucharest
x 94
Contact:

Re: time elapsed exception

Post by tod »

I would guess it's still an overflow. Double check that you don't write over the allocated memory.
machineonpointer
Kobold
Posts: 35
Joined: Fri Dec 06, 2013 4:15 am

Re: time elapsed exception

Post by machineonpointer »

tod wrote:I would guess it's still an overflow. Double check that you don't write over the allocated memory.
If it's caused by some stack overflow or heap overflow, the program will reboot, but it did not. May it be the floating-point-number overflow?
User avatar
tod
Troll
Posts: 1394
Joined: Wed Aug 02, 2006 9:41 am
Location: Bucharest
x 94
Contact:

Re: time elapsed exception

Post by tod »

I'm not talking about writing outside the stack or heap. I'm talking having a variable, like a string with 50 chars for example and writing 51 chars in it. The var declared after it will have it's value modified. In debug mode you may get an exception, but not always.
It would be hard for the floating point to overflow. I'm not sure it's a floating point underneath, it's probably a long integer anyway. A 32 bit integer will cover about 50 days if you store milliseconds.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: time elapsed exception

Post by Kojack »

You shouldn't really call windowMovedOrResized every frame.
It should only be called if you manually created the window (if ogre created it, it handles this internally) and only when the window actually moves or resizes.
machineonpointer
Kobold
Posts: 35
Joined: Fri Dec 06, 2013 4:15 am

Re: time elapsed exception

Post by machineonpointer »

I still cannot find out the code causing the bug. But the exception always happen when Ogre::ParticleSystem is created or the node it attached to is added as child of root scene node of Ogre Scene Manager.
Post Reply