PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

PocketFrog Bug - Dell Axim

After a lot of testing, I think I have isolated a bug with Pocket Frog and the Dell Axim. At first, I thought it was the Hekkus system (which I am using for my sound), but after running a simple PF demo program, I see the same Error (without Hekkus).

To reproduce the Bug, please try the following:

1) Compile and download ANY of the Pocket Frog (0.7) sample programs to your Pocket PC (I tried the Plasma demo on my Dell Axim).
2) Start Pocket Frog sample program on your Pocket PC.
3) While the sample program is running, press the power button on your Pocket PC to turn it off
4) Press the power button again to turn Pocket PC on

When you power-up the Dell Axim, the Info screen appears showing the owner name. After tapping the screen to return to the Plasma program, you will get the following "Fatal Application Error":

Application Plasma.exe has perfomed an illegal operation and will be shut down.

Program: Plasma.exe
Exception: 0xc000005
Address: 01fc7800

This is a repeatable bug on the Dell Axim.

Before someone says this is a "focus" problem, Pocket Frog 0.7 is supposed to account for this automatically. So, I'm not convinced this is the problem. I would assume the "sample" programs should not generate fatal application errors.

Can other Dell Axim users try this and let me know if you get the same error?

Thanks!
:D
Why dont you use your debugger and tell us where it crashes? Just complaining there is an AC in PF is not helping much.
I notice that you mention the owner information. On my Axim I don't have the owner information appearing on power on and my game comes back fine from power off. If I tick owner info to appear then it crashes. If you can do as Thierry suggests & post some debug info to assist please do so otherwise I can also do this as & when time allows.
I've experienced something similar to this time and again. Whenever a system message interrupts my PF 0.7 apps on the device, they crash (silently). A simple power off/on is fine, but a low battery warning, or flipping back to the Activesync connection dialog, kills it. It simply doesn't appear in the list of running programs.

I also use Axims...

-John
Please don't think that I am "complaining" about PocketFrog. Believe me, I am *extremely* grateful for PocketFrog as it has saved me so much time and headaches that I WAS having before I started using it. PocketFrog gave me the tools to do more than I could ever do on my own.

I've been coding for the PalmOS for the past 3 years, so I'm certainly not an expert in the Windows arena. My first port to the Pocket PC is almost finished (thanks largely to PocketFrog), and this application error is the only remaining problem that I have left to fix.

I would gladly do my part to help debug this problem, but coming from Palm OS development, I'm not very savy with the debugger. How do I debug a program on an actual device? I've been developing in Visual C++ on my computer and then downloading to my Axim for the final testing. If someone can give me some quick instructions on how to get debug info on this error, I will gladly post my results.

Thanks guys!
:)
If you want to try a device debug yourself make sure that you have the latest active sync & within evC3++ do a build of a debug version after setting all it's project settings & tools options setting so as to pick up the correct PF lib, PHAL lib & pointing to the correct includes & library folders just like your release one.

When you do a build & it downloads the debug version to the device you can then do a build / start debug / go & the app will start on the device.

However: when you power off the device activesync stops working so I cannot tell what the debugger was doing. Then evc++ crashed & exited.
I can try the Entrek debugging tools demo:- When the app crashes on power off the Entrek tool stops giving data.

So I think it's a new question: What actions must a developer take other than suspending Hekkus when a suspend happens? Should the game's main loop check every time & do nothing if suspended or what?
Thierry, was PF *ever* coded to handle these types of situations? I only ask because I didn't add any functionality in this regard to the later versions, so if it wasn't there to begin with, there's the problem.
I tried for over an hour last night to get the debugger to break where the error occurs, but I still didn't find anything. So, I guess no one knows how to fix this bug? I would try to dig around in the Pocket Frog code, but I don't even know where to start. :(
Aren't you supposed to check to see if the pointer to the display is valid before using it?

Looking at the plasma demo, in the gameloop section, it only has

DisplayDevice* display = GetDisplay();

and nothing like

if(display == NULL) return;


Try adding that and see if it still crashes.
I have just tested this with PocketHAL 0.7.1 and it doesn't crash. Hopefully the next PocketFrog (using PHAL) will be released soon.
does this mean that in PocketFrog everywhere displaydevice is used I need to add in functionality to test if it's valid before doing anything with the screen?

or can I do something 'globally'
I tried checking the display pointer for NULL (before using it), but I'm still getting crashes. I guess I'll just have to wait for the next version of PocketFrog (using PHAL) to be released. Hopefully it wil be soon! :D
Ok, not saying I'm holding all the answers (heck, I don't even own a PDA) but here's my guess:

The "Exception: 0xc000005" is an "Access Violation" which happens if you try to read/write from/to a NULL pointer or a dangling pointer (i.e. a pointer to a piece of memory that is not valid).

Conan wrote: "does this mean that in PocketFrog everywhere displaydevice is used I need to add in functionality to test if it's valid before doing anything with the screen?"

No, because if you managed to start your game using Game::Run() (which in turn calls Game::Init() followed by Game::GameInit() and then continuesly calls Game::GameLoop()) then it has already created the DisplayDevice for you and verified that it is not null. If it was, then Game::Init() would have returned false and Game::Run() would have exited with an error and not ever call Game::GameInit() or Game::GameLoop().

This is good news because it meens that you don't need to worry about the DisplayDriver (unlike what fast_rx suggested earlier).

But the bad news is (and this is once again traced back to the file pocketpc.cpp) is that the global pointer pointing to the DisplayDriver is never freed on a shutdown or exit. Normally this is not a problem since when a program exits all its memory are returned to the OS (but don't bet on it). I don't know exactly what happens on a Dell Axim when the power button is pressed so from this point on I'm only speculating:

It sounds like it goes down to some powersleep mode. And for some reason when it gets back, since its not going straight to your game (like Conan said worked flawlessly), it invalidates your DisplayDriver OR your program jumps on the GameLoop to fast (writing to the DisplayDriver if you are not the owner (i.e. has the focus) will also create this error).

So, I suggest you try three things:

1. Try adding a Sleep(1000) in Game::OnActivate before calling PocketPC::Resume(). It's a long shot but it could work.

2. Add a function to pocketpc.cpp that sets the global pointers to NULL (or 0) so you can try to reinitialize the DisplayDriver. Unfortunately there will be difficult to separate this behaviour from when the game only looses focus. And you don't want to create a new DisplayDriver every time (if that is even possible) because this will use up your memory eventually. Also, to be able to reinitialize you have to modify the Game interface and add a function here that does this for you (since all the stuff you need is private and you need a public or protected interface to use it).

3. Disable this owner info if that is what's causing the problem and you have no problem with normal suspend/resumes.

Not sure if this helped anyone. Sorry for a confusing and long post.
Wow, thanks for your detailed suggestions. I will certainly give them a try and see if they provide a solution.

About solution #3: Yes, you can always disable the "info" screen on power-up on the Dell Axim (which will prevent PF from crashing). However, I can't guarantee that every customer will have this screen disabled. And if not, my PF application will crash if they cycle the power or on a system window pop-up.
where do I find
Game::OnActivate before calling PocketPC::Resume().

I'm in the same boat as I'm trying to complete a game & hitting this problem & another crash/silent exit error what I'm tryng to resolve.
Conan, which version are you using? PF 0.7?

I will try to reproduce and fix tonight.
I reproduced with PF 0.7 and fixed. Simply edit class Game.h and remove the "OnSetFocus" and the "OnKillFocus" callbacks.

You need to remove the two functions from Game.cpp and remove the two entries in the message map (Game.h).

I don't know what I was thinking when I used these callbacks. OnActive() is the (only) way to go to handle this issue.
Thanks Thierry, I will implement tomorrow (next time I get sufficient desk time, all coding on a train today so VC6 only. I'm using PF 0.7.0 having switched over a couple of weeks back. Also about to try the V4 compiler to see if my silent exit & crash are affected. Game is code complete other than crashes.
WooHoo!!! :D Thanks Thierry! I really appreciate your help on this one. This bug has been bothering me for quite some time...I'll be glad to have this problem behind me.

Thanks again!
WOOOOOOOHOOOOOOOOO Indeed.

This fixes my silent exit when my app loses focus to system messages (low battery warnings, activesync message box, etc).

You rock, Thierry!

-John
Awesome! I am glad it fixes all your existential problems!
Thierry wrote:I don't know what I was thinking when I used these callbacks. OnActive() is the (only) way to go to handle this issue.

Can you please explain how removing the two callbacs could make a difference what so ever? Because you would expect that they would just be redundant. Looking at the code (first glance) it looks as if OnSetFocus/OnKillFocus just calls OnActivate which uses a member flag to keep track of the suspend state. Meening that it doesn't matter if you try to suspend or resume more than once since any subsequest calls will just be ignored.

Ok.. so much for the PF code part. I suspect that the problem lies in the way your program gets the window messages. Is it possible to get a WM_SETFOCUS event message BEFORE the other window gets his WM_ACTIVATE(WM_INACTIVE) message? (resulting in us trying to write to the screen even though we're not proper owners of it yet, causing this 0xc000005 error).

Or let me refrase: In what order are the WM_ACTIVATE and SET/KILLFOCUS sent? This is what MSDN says about WM_ACTIVATE: "This message is sent when a window is being activated or deactivated. This message is sent first to the window procedure of the top-level window being deactivated; it is then sent to the window procedure of the top-level window being activated." But it doesn't say anything about how this is related to the SET/KILLFOCUS events. This would be really interesting (and useful) to know.
An application activation status has nothing to do with it's input focus. It is obvious to me (now) that focus issues shouldn't be handled at all. In fact, it's the activation state you care about.

I haven't spend the time figuring out exactly what was the interaction problem between WM_ACTIVATE and WM_SETFOCUS in PF0.7.
I really don't understand the specifics of this bug. However, removing the callbacks does fix the problem! My PF app now works flawlessly with pop-up alerts, focus changes, etc. I'm happy to say I haven't seen a 0xc000005 exception since I removed the callbacks. Thanks again Thierry! :D
I've noticed that with PC builds, the GameSuspend() and GameResume() isn't called... At least on my system...

Same before and after the fix mentioned above.


The gameloop does get paused, though...
Conan · 16 Jun 2004, 12:03 UTC — Program exits after restart with the suggested changes
Having taken out the two functions OnSetFocus and OnKillFocus I tested with the owner info turned on at startup. Now instead of the game crashing it's just not there. Not in task list nothing, just gone?

Do I need to add any functionality to handle the activate stuff?
Conon: can you test with the samples and see what you get?
Will do. I think my game is 'vanilla PF' but once I try a sample I will report back. Might be Friday as I don't always get time near a real device to test.

.... a few minutes later ....
I managed to try the Plasma sample & my own sprite sample & both work ok which I guess points to Hekkus as a possible reason for the difference. I will try the Hekkus demo when I get it to build ok.
I'm using Hekkus in my PF app, and after following Thierry's instructions, everything works fine for me. I originally contacted the author of Hekkus about this problem, but soon isolated the problem to be with Pocket Frog and not Hekkus. I'm sure you will find the same.

But again, if you follow Thierry's instructions, everything should work even with the info screen enabled on your Axim....it did for me. :D