Hello!
I am using the profiling version of POSE 3.1 (Emulator_profile.exe). I
use the host functions to activate profiling. Unfortunately, POSE counts
every iteration through my applications main event-loop as a recursive
method call (it is actually a while-loop). This results in an overflow
of the maximum recursion depth rather quickly. What might cause this
strange behavior?
Profiler text-file:
-----------------
index parent depth function name count only cycles only msec only % plus
kids cycles plus kids msec plus kids % average msec max msec interrupt
msec interrupt count/debug
146 -1 0 functions 0 0 0.000 0.0 42588128 2568.000 0.0 -1.#IO 0.000
0.000 2
210 146 1 AppEventLoop__Fv+$0150 1 542 0.000 0.0 42384634 2556.000 0.0
0.033 0.033 0.035 10002
367 210 2 AppEventLoop__Fv+$0150 1 542 0.000 0.0 42185020 2544.000 0.0
0.033 0.033 0.035 10002
523 367 3 AppEventLoop__Fv+$0150 1 542 0.000 0.0 41985030 2532.000 0.0
0.033 0.033 0.035 10002
<... and so on...>
/**
* The event loop for the application.
*/
static void AppEventLoop()
{
UInt16 error;
EventType event;
Boolean redrawWhenReturningToGameWindow;
// The game has not yet begun. Let PalmOS handle all events until
// frmOpenEvent has been received on the Main form.
do
{
EvtGetEvent (&event, evtWaitForever);
if (! SysHandleEvent (&event))
if (! MenuHandleEvent (NULL, &event, &error))
if (! AppHandleEvent (&event))
FrmDispatchEvent (&event);
} while ((event.eType != appStopEvent) &&
(!(presentation->hasBegun())));
do
{
// Wait until the next game period.
EvtGetEvent (&event, presentation->getTimeUntilNextPeriod());
// Detect exiting the game's window. This must be checked for. At
this
// point there probably exists another window which may cover part of
// the MainView window. Suppress drawing. Otherwise drawing may draw
// to part of the window covered by the new window.
if (event.eType == winExitEvent)
{
HostTraceOutputTL(appErrorClass, "Starter: winExitEvent");
if (event.data.winExit.exitWindow == (WinHandle)
FrmGetFormPtr(MainForm))
{
presentation->pause();
}
}
// Detect entering the game's window. Resume drawing to our window.
else if (event.eType == winEnterEvent)
{
HostTraceOutputTL(appErrorClass, "Starter: winEnterEvent");
// In the current code, the menu doesn't remove itself when it
receives
// a winExitEvent.
if (event.data.winEnter.enterWindow == (WinHandle)
FrmGetFormPtr(MainForm) &&
event.data.winEnter.enterWindow == (WinHandle) FrmGetFirstForm ())
{
// Sometimes we can enter the game's window without knowing it was
// ever left. In that case the pause time will not have been
recorded.
// Presentation is smart enough to handle that, and will set the
current
// period back to it's beginning.
presentation->resume();
// Redraw the game window. This is normally triggered when the
launcher
// is activated during a low heap memory condition to work around a
launcher
// bug which causes it to fail to send a frmUpdateEvent when it
doesn't
// restore the bits underneath it.
if (redrawWhenReturningToGameWindow)
{
presentation->redraw();
redrawWhenReturningToGameWindow = false;
}
}
}
else
{
if (event.eType == keyDownEvent)
{
HostTraceOutputTL2(appErrorClass, "Starter: keyDownEvent %hu %hu",
event.eType, event.data.keyDown.chr);
}
else
{
HostTraceOutputTL1(appErrorClass, "Starter: event %hu",
event.eType);
}
presentation->receiveEvent(&event);
// If it's time, go to the next time period
if (presentation->getTimeUntilNextPeriod() == 0)
{
presentation->nextPeriod();
}
}
if (event.eType == nilEvent)
continue;
// Treat virtual keys properly. Some can safely be ignored,
// others require the display to be released, so they can show
// their dialog boxes.
if ((event.eType == keyDownEvent) && (event.data.keyDown.modifiers &
commandKeyMask))
{
WChar chr = event.data.keyDown.chr;
// Swallow events notifying us of hard key presses. We poll instead.
if (chr >= vchrHard1 && chr <= vchrHard4 &&
!(event.data.keyDown.modifiers & poweredOnKeyMask))
{
continue;
}
// Ignore these
else if (
chr == vchrCommand || chr == vchrFind || chr == vchrCalc ||
(chr >= vchrTsm1 && chr <= vchrTsm4) || chr == vchrKeyboard || (chr
>= vchrRonamatic && chr <= vchrKeyboardNumeric)
)
{
continue;
}
// Release display for these
else if (
chr == vchrAlarm || chr == vchrLock || chr == vchrLowBattery || chr
== vchrBrightness || chr == vchrContrast ||
chr == vchrHardBrightness || chr == vchrHardContrast
)
{
HostTraceOutputTL(appErrorClass, "Starter: pause b/c vchr");
presentation->pause();
}
// Handle a launcher bug. It can fail to send a frmUpdateEvent.
if (chr >= vchrLaunch)
{
UInt32 freeBytes;
UInt32 maxChunk;
const UInt32 saveBitsThreshold = 4000;
MemHeapFreeBytes (0, &freeBytes, &maxChunk);
if (freeBytes <= saveBitsThreshold)
{
redrawWhenReturningToGameWindow = true;
}
}
}
if (! SysHandleEvent(&event))
if (! MenuHandleEvent(0, &event, &error))
if (! AppHandleEvent(&event))
FrmDispatchEvent(&event);
} while (event.eType != appStopEvent);
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/