BASIC

Author Topic: iPhone 'resume'  (Read 4245 times)

Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
iPhone 'resume'
« on: 2010-Aug-16 »
Sorry if this has been asked before - couldn't find an answer anywhere.

We've had it pointed out that our game does not support resume on an iPhone (after a call interrupts a game or whatever), and that this is an essential feature.

It's not something I can easily test, unfortunately, so I'd like to know how the iphone deals with this, and how glb interprets that. Does the app simply loses focus and therefore 'autopause true' would solve this problem? Or does it essentially exit the app, calling glb_on_quit, and therefore I'd need to implement a save state and reload everything?

And while I'm asking, is multi-tasking on iOS4 the same or different? ie, if someone double-taps and starts a different app, does it lose focus? can i make my glb app 'os4 multi-task capable'?


Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
Re: iPhone 'resume'
« Reply #1 on: 2010-Aug-16 »
After some testing with multi-tasking on a later generation iPod Touch which supports multi-tasking, we have found that 'autopause true' causes the following behaviour:

IF you switch between our glbasic app and another running app, and switch back to it, it works. Our game continues where it left off.

However, if you switch from our app to another app and CLOSE that other app then switch back to our app, the app immediately quits.

Which, presumably, means that this is precisely what it would do when put on hold to receive a call on an iPhone, because you would exit the phone app on finishing the call. We're currently trying to get this tested on an iPhone, and I'll update our findings if we are able.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10682
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iPhone 'resume'
« Reply #2 on: 2010-Aug-16 »
OK, thanks. Can the iPad do Multitasking in 3.2? I might be able to test that then.

Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
Re: iPhone 'resume'
« Reply #3 on: 2010-Aug-16 »
OK, thanks. Can the iPad do Multitasking in 3.2? I might be able to test that then.

As far as I know, no. Not until iPad gets upgraded to 4

Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
Re: iPhone 'resume'
« Reply #4 on: 2010-Aug-16 »
The error we're getting in xcode debugger is:

sgx error (background gpu access not permitted):
Program received signal: “SIGABRT”

Which sounds to me like it's attempting a showscreen once it's lost focus, and can't.

I tried using HIBERNATE to prevent it doing that in the main loop, since the next thing we're expecting is a user touch, but unfortunately, we get a very noticeable flash to black of the whole screen when using this command, so unless we could solve that issue, it wouldn't even be worth trying.

Not trying to teach anyone to suck eggs, but I wondered if the following thread might help?

http://www.cocos2d-iphone.org/forum/topic/7326

Kitty, if you have skype or something, Mike could show you what's happening on a multi-tasking device by video if it's of use?

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1540
    • View Profile
Re: iPhone 'resume'
« Reply #5 on: 2010-Aug-16 »
OS4 for iPad may be as far as 3 months away and my iPod with OS4 doesn't multitask so I have no way to physically test or answer this currently.

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 929
  • KodeSource
    • View Profile
    • KodeSource
Re: iPhone 'resume'
« Reply #6 on: 2010-Aug-16 »
As an Apple Developer you can always upgrade to 4.0 for testing.

Quote
Registered Apple Developers can access iOS SDK 4 for developing iPad, iPhone and iPod touch applications.

http://developer.apple.com/iphone/index.action

However, I'm not sure how difficult it is to revert back to 3.2.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
Re: iPhone 'resume'
« Reply #7 on: 2010-Aug-17 »
It seems there might be a more fundamental problem here with glbasic apps on a multi-task capable iPod/iPhone. It's not just down to setting AUTOPAUSE.

The error I mentioned before, that it's trying to write to the screen while it's a background task, happens anyway. This causes the app to error (see the thread I linked) and then immediately terminate when it's brought back to the foreground.

The thing is, it seems a device that DOES have multi-tasking puts an app to the background EVEN if you exit 'normally' with a single tap of the Home button. What this means in practice from all my testing so far is that GLB_ON_QUIT never fires. At all. Ever.

If your device doesnt support multi-tasking, it works like OS3, and therefore GLB_ON_QUIT fires.

Which means that not only can we not support resume, but I can't even write a save state/load state function myself that will work on a newer iOS4 device.

I'm almost inclined to believe that, for some reason I can't fathom, I'm wrong about this... because surely some of you guys have games that utilise GLB_ON_QUIT and you would have been deluged with complaints of saves and stuff not working if that was the case?!

By the way, this is true of glb7 and glb8.

Kitty, do you want me to summarise this in Bug Reports or anything? If what my testing indicates is true, it's quite a big problem!
« Last Edit: 2010-Aug-17 by jaywat »

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 929
  • KodeSource
    • View Profile
    • KodeSource
Re: iPhone 'resume'
« Reply #8 on: 2010-Aug-17 »
New subroutines may need to be added to GLBasic, and/or the existing 'GLB_ON_QUIT' be modified to be called even on being suspended to the background. 
But then you would need a corresponding 'GLB_ON_RESUME' or something. 
Or, I think you can force an app to only quit, and not multi-task, when pressing the button.

Details of the new iOS4 multi-tasking can be found here:
http://developer.apple.com/iphone/library/documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
Re: iPhone 'resume'
« Reply #9 on: 2010-Aug-17 »
New subroutines may need to be added to GLBasic, and/or the existing 'GLB_ON_QUIT' be modified to be called even on being suspended to the background. 
But then you would need a corresponding 'GLB_ON_RESUME' or something. 
Or, I think you can force an app to only quit, and not multi-task, when pressing the button.

I think you are probably right, and I'd really consider this a priority fix request. Firstly, because we have customers are crying out for this functionality in my app.  But mostly because as far as I am aware, when iOS4 for the iPad is released, you will HAVE to build your apps for OS4 as a condition of acceptance. Deploying for OS3 is only allowed now so you can develop for iPad.

I'm actually quite surprised that our apps are getting accepted considering that they're only actually exiting by virtue of the fact they crash (on a multi-tasking capable device).
« Last Edit: 2010-Aug-17 by jaywat »

Offline jaywat

  • Mr. Drawsprite
  • **
  • Posts: 68
    • View Profile
Re: iPhone 'resume'
« Reply #10 on: 2010-Aug-18 »
I have made a bug report here, since this problem affects ALL glbasic apps built for and running under OS4, where they will crash on an iPhone or iPod supporting multi-tasking, which I think makes it a fairly major bug, even if no one else seems very interested.  ;/

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10682
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iPhone 'resume'
« Reply #11 on: 2010-Aug-19 »
OK, I think I fixed it. See the current online manual for AUTOPAUSE to see what I did.
I'll make an update soonish.