Author Topic: iPhone/iPod Apps crash on exit under OS4  (Read 8800 times)

Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
I'm making a thread about this here because although I've extensively covered the findings of a days testing in another thread, I didn't want the point or the implication to get lost or diluted.

Simply put, ALL glbasic applications (as far as I can tell) built for iPhone OS4 and deployed for 3.x, which I believe is Apple's requirement for acceptance, will crash on exit on any iPhone or iPod that supports multi-tasking (ie, a very large number of devices). In doing so, GLB_ON_QUIT is never called. The implication of this, of course, is that any state saving or tidying up you try and do on exit never happens.

Under OS4, any device supporting multi-tasking apparently ALWAYS puts the app to the background when you exit, whether you exit normally, or exit to the multi-tasking bar. Glbasic apps, though, seemingly  cant recognise that it's a background task and will try to illegally write to the screen with SHOWSCREEN, and generates an application error, "background gpu access not permitted", which results in the application crashing immediately without executing any further code.

From the Apple documentation:

Quote
Do not make any OpenGL ES calls from your code. You must not create an EAGLContext  object or issue any OpenGL ES drawing commands of any kind. Using these calls will cause your application to be terminated immediately.

This is the same for GLB7 and GLB8. The same code used for testing does indeed quit successfully when compiled and built for OS3 only, but of course that isn't really the point, other than to demonstrate that this is a problem with glbasic and OS4.

I also noted in the other thread that I had tried both with and without 'AUTOPAUSE TRUE' with the same results. I also noted that using HIBERNATE to halt showscreen calls wasnt really an option because it causes the application screen to flash to black every time we update the screen.

Admittedly, testing isn't made easy by the fact I have to send code to Mike to compile for xcode, run on a device I don't have access to,  and then watch the results by screensharing or video ;)

I'd really appreciate if this could be looked at as soon as possible; for us, at least, it's pretty much a 'show stopper'; and that includes our just released app getting an update... not only can we not support pause and resume, but we can't even code our own save and load. And if you haven't had this problem, then thats just because you haven't released an app or update since OS4!

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10839
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iPhone/iPod Apps crash on exit under OS4
« Reply #1 on: 2010-Aug-19 »
it's fixed in the next update. You get notified with SUB GLB_ON_PAUSE and GLB_ON_RESUME about that states. (Also when a call kicks in)

Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
Re: iPhone/iPod Apps crash on exit under OS4
« Reply #2 on: 2010-Aug-19 »
Looking forward to the update - I've already written a bunch of test code :)

Does it safeguard against doing a showscreen while GLB_ON_PAUSE, or is it a case of 'never use showscreen while paused or your app will crash!'. If the latter, I'd suggest this is made very clear in the user manual.


MrTAToad

  • Guest
Re: iPhone/iPod Apps crash on exit under OS4
« Reply #3 on: 2010-Aug-19 »
Will ON_PAUSE/RESUME work on Windows/Linux etc to detect when a window is minimised ?

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10839
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iPhone/iPod Apps crash on exit under OS4
« Reply #4 on: 2010-Aug-19 »
Windows, yes. I have to see if I get that event in Mac/Linux, too.

Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
Re: iPhone/iPod Apps crash on exit under OS4
« Reply #5 on: 2010-Aug-24 »
I've posted extensively on my experiences of using GLB_ON_PAUSE and GLB_ON_RESUME in the newly released 8.078 in the announcement thread here, complete with test code that highlights some of the problems I've discovered.

I think there are definitely some issues at the moment, and at the very least we need some clarification of what is or isn't acceptable to put in these new subs.

Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
Re: iPhone/iPod Apps crash on exit under OS4
« Reply #6 on: 2010-Aug-25 »
Just to confirm for clarity, since there's several different conversations going on at once in the V8 thread, that despite the implementation of GLB_ON_PAUSE and GLB_ON_RESUME in v8.078, the originally described issue still exists. That is, a GLBasic app crashes after trying to write to screen while a background task when on an iPod or iPhone that supports multi-tasking. This happens even on a normal exit, not just when put to the multi-tasking bar.

Tested using Gernots own example code and the same described implementation used to update our existing apps.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10839
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iPhone/iPod Apps crash on exit under OS4
« Reply #7 on: 2010-Aug-25 »
Yes. Do not do that. You can check if you're background or not with the given callback subs.

Or am I not understanding you at all?

Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
Re: iPhone/iPod Apps crash on exit under OS4
« Reply #8 on: 2010-Aug-25 »
I guess you're not understanding me. Your new subs do not appear to prevent the issue that GLBasic apps crash, even when used to detect the state changes, even when used as described.

This code (your code, albeit i added a counter so you could see it 'do' something) does not work on a multitask device. At least, the app crashes and restarts from the beginning on resume. Even though I've implemented your subs, exactly as you recommended. xcode says that you tried to write to gpu while a background task. Thing is, this is exactly how it behaved before you even implemented them.

Code: (glbasic) [Select]
AUTOPAUSE TRUE
GLOBAL gPause=FALSE
GLOBAL a%

game:
IF gPause
   DisplayPauseMessage();
   SHOWSCREEN                        // as I understand it, if gPause is true, it just halts part way through execution of this? Except iPhones still crash.
   MOUSEWAIT
   gPause = FALSE     // ok, this wasn't in your code... but I assume this is what you expect me to do, or it never exits the pause state to resume?
ELSE
   UpdateGame()
   DrawGame()
   SHOWSCREEN
ENDIF
GOTO game


FUNCTION DisplayPauseMessage:
PRINT "I am paused",0,0
PRINT "Touch to continue",0,20
ENDFUNCTION

FUNCTION UpdateGame:
INC a%
ENDFUNCTION

FUNCTION DrawGame:
PRINT a%,0,0
SHOWSCREEN
ENDFUNCTION


SUB GLB_ON_PAUSE:
gPause=TRUE
ENDSUB

SUB GLB_ON_RESUME:

ENDSUB

« Last Edit: 2010-Aug-25 by jaywat »

MrTAToad

  • Guest
Re: iPhone/iPod Apps crash on exit under OS4
« Reply #9 on: 2010-Aug-25 »
It sounds like the gPause section is being executed slightly after the program has been minimised and thus executing SHOWSCREEN when the program is a background task (or gPause isn't being updated quick enough).

Perhaps it might be worth telling the OS that you need more time to complete a task ?

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10839
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iPhone/iPod Apps crash on exit under OS4
« Reply #10 on: 2010-Aug-25 »
set the gPaused flag only in GLB_ON_PAUSE and GLB_ON_RESUME. Very strange. It worked nicely on my device.
... darn I lost the test code I was using.

Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
Re: iPhone/iPod Apps crash on exit under OS4
« Reply #11 on: 2010-Aug-25 »
set the gPaused flag only in GLB_ON_PAUSE and GLB_ON_RESUME. Very strange. It worked nicely on my device.
... darn I lost the test code I was using.

I was under the impression you didn't have a multi-tasking device to test on? Yes. This code works on a non multi-tasking iPod or iPhone. But then our games don't all crash on a non multi-tasking device either.

On any that do support it, they crash.

Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
Re: iPhone/iPod Apps crash on exit under OS4
« Reply #12 on: 2010-Aug-25 »
set the gPaused flag only in GLB_ON_PAUSE and GLB_ON_RESUME.

Ok. Moving gPaused flag setting to GLB_ON_RESUME works with that code (in which case I don't understand why the FIRST code I posted didn't work!), BUT the app STILL crashes on a normal exit without visiting GLB_ON_QUIT, producing the 'background GPU access' violation.

EDIT: However, it actually DOESNT work when applied to our games. The exact same method. I have a conditional statement round my main loop, I set a paused flag in GLB_ON_PAUSE and unset it in GLB_ON_RESUME, I have EXACTLY the same 'touch to continue' code as the test code, aaaaand it starts from the beginning when resumed. Exactly the same method. I'm not posting my game code, because if it's THAT hard to implement a pause and resume using the same method in two different apps, then frankly there's a problem with GLBasic, not with my code.

I give up. We're getting nowhere with this and I've wasted hours and hours trying to get something that works and tried to be as helpful as possible, posting pages and pages of my findings here, doing testing that no one else here apparently is able to or cares about (I don't really know why other GLBasic iPhone app developers aren't concerned that their apps are crashing, but it seems I'm the only one...) ... and then get asked if I'm sure I'm using a multi-tasking device!

Even if GLBasic doesn't support resume I'd just be happy to be able to update my games so they don't crash... but the fact is still the same as it was in my first post over a week ago:

ALL GLBASIC APPS CRASH ON EXIT. Or put another way: GLBasic is incompatible with iOS4.

I'd say the fact that GLBasic apps are even passing approval is sheer luck, given that they all commit the cardinal sin of writing to screen while a background task. Well, unless you have an old device that doesn't support multi-tasking at all, in which case you're just fine. But 50% or so of my customers have an issue, and it's not like there's anything I can do anything about it.

I really have no option but to stop using GLBasic for development until it is compatible with OS4. Sorry, but this is just hopeless.
« Last Edit: 2010-Aug-25 by jaywat »

MrTAToad

  • Guest
Re: iPhone/iPod Apps crash on exit under OS4
« Reply #13 on: 2010-Aug-25 »
Sure you set the correct XCode settings for OS 4 ?

Offline mykyl66

  • Mr. Polyvector
  • ***
  • Posts: 114
    • View Profile
Re: iPhone/iPod Apps crash on exit under OS4
« Reply #14 on: 2010-Aug-25 »
Yes the settings are set correctly for ios 4. Yes we are using a multitasking machine for testing. No we cannot get it to work as described. Yes our customers want a simple way to resume, but right now we'd settle for our apps not crashing.

Cheers

Mike R