Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

iOS and MacOS / iOS END command does not close app

Author
Message
Naphier
11
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 18th Nov 2013 05:46
In our game you can press the icon in the upper left to close the app, however this just causes a black screen and the app doesn't actually close.

Not a huge deal because I can just shut off that functionality. However, I do have programmed in validation checks that I've allowed to cause "fatal errors" which I want the app to shut down. And in iOS it looks like whenever the END command is called it is completely ignored.

Any tips?

Ancient Lady
Valued Member
18
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 18th Nov 2013 13:35
The AppGameKit 'End' does, in fact, not work in iOS (or in Android, for that matter).

If you were using Tier 2, you can force the app to close with these commands, in both platforms:


However, they are not available in Tier 1.

If you can find the place in the interpreter.cpp file that handles the 'End' command, you could edit it to use the commands above, I suppose. But I don't know what affect that would have on anything else.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Naphier
11
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 18th Nov 2013 14:38
Thanks. I'll have to figure out if I want to risk changing interpreter.cpp or just disable the "exit button" and make my fatal error just go into a loop instead...
In Android this does work just fine 99% of the time. The other 1% of the time it closes the app and you see a stopped responding message. That seems to happen with a lot of non-AGK apps though so I wasn't overly worried.

Naphier
11
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 18th Nov 2013 17:32 Edited at: 18th Nov 2013 17:33
So I got brave and here's what I found:
In interpreter.cpp there are two functions
CloseApp() and End()
I cannot find where End() is ever called in interpreter.cpp
If you add agk::MasterReset() and exit(0) to the End() function it does nothing.
I tried calling the End() function from CloseApp with exit(0) called (CloseApp calls MasterReset already) and the app would just freeze when I tried to force exit. I later found out this was because I was causing an infinite loop because End() calls CloseApp()...

So what I did in the end is have CloseApp call End() because End() frees up some resources (although they look like they are just ones for the player). And inside of End() I call Exit(0)

It seems to work just fine so far. I've tested it a bit and nothing noticeably wrong happens.

So in interpreter.cpp
at line 3696 or so inside of CloseApp() call End()
at line 3732 or so inside of End() call exit(0)

I think I'll be adding this to the Android version too. Now If I could only find an easy way to deal with the notification bar in iOS 7...

And thanks for the tip!!

Ancient Lady
Valued Member
18
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 18th Nov 2013 18:29
Thanks for working out the details for inside interpreter.cpp. I am sure this will help a lot of people.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Naphier
11
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 18th Nov 2013 18:30
Glad you pointed me there. It was super easy.

Login to post a reply

Server time is: 2022-09-25 22:52:02
Your offset time is: 2022-09-25 22:52:02