PocketMatrix forums

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

PHAL problems on e750

Hey Thierry,

I've been trying to help Kak (CEdiCE maker) run down a problem with his game locking up with loss-of-focus.

I wanted to look at some things myself and go the latest 0.7.2 so I could look at some samples. The won't run on the toshiba e750, although it does run on my wife's viewsonic - so I know I'm compiling it right.

Some observations:
When I run the fireworks or minimal sample, I hear a windows error. And I can hear the beeps of the start menu and all, but the screen is actually showing the last screen from Kak's game. Even after re-setting the device!

Also, note that Kak's game runs fine - it's just that it doesn't handle loss-of-focus and will only run 1 time (the next time I just see the last image from the game - similar to what happens in the samples except that I don't hear the windows error beep).

Let me know if you want any more info or a run of a test of some sort... After all, I want the new PHal based pocketfrog to work on my device
:D


One more thing I noticed. The minimal sample compiled and linked without the lib path to phal. For the fireworks to link, I had to add the path. What's the trick to that? An autolink something-or-other?
My wedding is tomorrow... At 11h AM... So little time to help you right now...

Meanwhile, if you could get someone to test this on the E740 (not E750, E740), it could help me narrow down the problem.

This could very well be a simply focus issue that was never reported/tested on E740/E750 before (I don't have access to such a device). In fact I have a pretty good idea what it could be. So much that I attached a potential fix to this message. It is version 0.7.2 with a potential fix to your problem. Please try it and let me know here.

Can you verify with Kak that his game is properly destroying the display object when quitting the game? How does he handle focus? (If at all?)
Attachments:
PocketHAL_ARM.zip (42 KB)
Thierry wrote:My wedding is tomorrow... At 11h AM... So little time to help you right now...

Meanwhile, if you could get someone to test this on the E740 (not E750, E740), it could help me narrow down the problem.


Hey, thanks a lot to both, really :) And good luck with your new life, Thierry! :)
It still doesn't work.

I put some OutputDebugString's in the minimal sample, and I'm suprised that it does initialize and run the game loop a couple of dozen times before it crashes (although nothing is actually drawn on the screen).

Since Kak's game uses 0.6.6, I linked in the 0.6.6 lib with the minimal sample in 0.7.2 and it worked. So Kak's problem may be unrelated to this.

So, Kak, are you "properly destroying the display object when quitting the game"?

I will have access to a 740 after the weekend.


Good luck with the wedding...
It feels as if the problem is something else then PocketHAL in Kak's game.

The Imageon 100 code for 0.7.2 is 100% the same one that was in 0.6.6. No change whatsoever.

If you run the 0.7.2 samples on a fresh device that hasn't seen Kak's game, what happens? Does it work? It should if 0.6.6 works.
I've compiled the fireworks sample with the 0.6.6 library, then again with the 0.7.2 library and saved them to the device under 2 names.

Immediately after a soft reset (not running Kak's game). I can run the 0.6 version, but the 0.7.2 version hangs immediately (if debugging- I get a first chance exception: Access Violation).

Is that what you meant by 'fresh'?
OK, something is definitely wrong with 0.7.2 then. Do you know where this access violation occurs? I.e. which DLL, function name, address, etc. Anything that can help me track it down?

Does it run for a few frames or does it hang right away?
I modified the gameloop in minimal.c to the following:

Code:

bool MinimalGame::OnGameLoop()
{
OutputDebugString(TEXT("start loop..."));


Display* display = GetDisplay();

OutputDebugString(TEXT("got disp..."));


if (display->BeginScene())
{

OutputDebugString(TEXT("render..."));


// Render one frame
PHAL::Surface * bbuff = display->GetBackBuffer();

if(bbuff == NULL)
{
OutputDebugString(TEXT("invalid bbuff..."));
}
else
{

OutputDebugString(TEXT("clearing..."));
Clear( display->GetBackBuffer(), m_currentColor );
OutputDebugString(TEXT("swapping..."));

display->Swap();
}
// Toggle color between white and black
if (m_currentColor != COLOR_GREEN)
m_currentColor = COLOR_GREEN;
else
m_currentColor = COLOR_RED;
}

OutputDebugString(TEXT("done\n"));


return Game::OnGameLoop();
}




Note the locations of the OutputDebug's...

and I get


Code:

start loop...got disp...render...clearing...swapping...done
start loop...got disp...render...clearing...swapping...done
start loop...got disp...render...clearing...swapping...done
start loop...got disp...render...clearing...swapping...done
start loop...got disp...render...clearing...swapping...done
start loop...got disp...render...clearing...swapping...Prefetch Abort: Thread=9b7c5e5c Proc=98413f90 'minimal.exe'
AKY=00008001 PC=00443228 RA=00013fcc BVA=00443228


I never see the color changing from red to green. And the debugger just jumps to a section of raw code.
"Prefetch abort"... Mmm. I wonder whats it means?

I did some googling and it seems to mean that an instruction was fetched from invalid memory. I wonder why this is happening in the case of the Imageon 100 driver (and was not happening in 0.6.6).
I think I found the problem. Please try this version.
Attachments:
PocketHAL_ARM.zip (42 KB)
Thierry, get back to your wife!
Thierry wrote:I think I found the problem. Please try this version.


It works!
Thierry wrote:
Can you verify with Kak that his game is properly destroying the display object when quitting the game? How does he handle focus? (If at all?)


Hi Thierry,

finally weekend again, back to home and the pleasure of a decent internet connection :) I hope your wedding went right and lots of future happiness :)

I've been testing with fast_rx (hey, lots of thanks for your patience) and we've reached this point:

I've compiled the game using the standar 7.2 framework (the same than firework example). The framework is unmodified except for an include and a little user minimize.

The tests behave this way:

run my game. runs nice. run again my game. it shows the last image I showed in the game. Create works (return a valid pointer), BeginScene fails (window has no focus? can it fail for another reason?)

run my game. runs nice. run the firework demo. fails, shows the last image I showed in the game. it seems that beginScene is failing again.


right now I'm proceeding to start removing parts of the game until I find a minimal example which fails, I'll keep you informed :)

Kind regards :)
Kak
BeginScene() is only supposed to fail if:

1) You app isn't at the front (i.e. the active app).
2) You call BeginScene() multiple times.
3) There is a bug in the Imageon driver.

At least we are making progress on this E740 thing. You might want to try the "minimal" simple and see how things go.

Keep me informed here!
Thierry wrote:BeginScene() is only supposed to fail if:
2) You call BeginScene() multiple times.


mmm... when is that repeat flag "reseted"? I mean, if I call BeginScene by error at the startup (I'm not doing that... I think :) ) and then I call it each frame, will it fail always?

anyway, what's the point of calling BeginScene if afterwards I'm calling GetBackBuffer which automatically calls it if not called? (personal rant)

Keep me informed here!

I'll do it :)
Kak wrote:mmm... when is that repeat flag "reseted"? I mean, if I call BeginScene by error at the startup (I'm not doing that... I think :) ) and then I call it each frame, will it fail always?


Next time your application becomes active, BeginScene() should succeed.

Kak wrote:anyway, what's the point of calling BeginScene if afterwards I'm calling GetBackBuffer which automatically calls it if not called? (personal rant)


GetBackBuffer() won't call BeginScene(). That was the behavior in 0.6.x and was changed in the 0.7.x branch.


Do you still experience problems on E740/E750?
Thierry,

I've been playing with some code from Kak to speed up this debugging process on the e750 problem.

It seems as if I'm re-creating the problem if I exit from the main game loop before the display->Swap() is called.

I've even tried it on the phal fireworks demo. This will exit the program, but any phal application run after this will just show the last phal buffer. The fireworks demo doesn't crash, it just never get's anything new on the screen.

Are you always supposed to make sure you call a Swap() after a successful GetBeginScene() or is this an isolated problem with the 750's?
I might have found the problem. It could indeed be related to calling BeginScene() and not Swap() before leaving the app.

Here is an updated version of PocketHAL 0.7.2 for ARM. Please try it as-is (without calling Swap) to see if it fixes the issue.

Could you also test for losing/gaining focus? Thanks for all your help!
Attachments:
PocketHAL_ARM.zip (42 KB)
Thierry wrote:I might have found the problem. It could indeed be related to calling BeginScene() and not Swap() before leaving the app.

Here is an updated version of PocketHAL 0.7.2 for ARM. Please try it as-is (without calling Swap) to see if it fixes the issue.

Could you also test for losing/gaining focus? Thanks for all your help!


ok, I'm compiling it again with the new version and sending it to fast_rx. Fingers crossed :)

btw, I had a MessageBox once the app ends (to show error messages), however since I started using the fireworks framework, the message appears a split second at the end and disapears without need to push the ok button.
I suppose it has something to do with the WM_QUIT message, I put the message box at the end of the GameBase::Run loop, once WM_QUIT has been received and breaked out of the main loop.
Which would be the correct place to show a MessageBox with the fireworks framework?

(the question might sound stupid, but I'm not good on windows programming :) )

TIA :)
Kak
Hi Thierry,

fast_rx reported that everything works properly :)

both the minimize/maximize functions and exiting the program without calling swap after a beginscene


> Both versions work properly.
>
> Also, I tested power cycling, network popup (accidentially),
> activesync
> connection, and user minimize - on the last one with the new PHal
> build.
> They all worked correctly.



lots of thanks to both for the support, it's really apreciated :)
Kak[/quote]
Thanks to both of you! I could never have tested this myself as I don't have access to a E740. The fact that nobody reported this before is puzzling...

Thanks again!
Thierry wrote:Thanks to both of you! I could never have tested this myself as I don't have access to a E740. The fact that nobody reported this before is puzzling...


well, I suppose the code was well done :) Nobody should probably do a beginScene without a flip, hence the problem.

I wish also to thank both of you, fast_rx did almost all the work to find it, and you for help and the library, of course :)

Kak