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.

AppGameKit Classic Chat / [SOLVED] Something changed with latest Android software update - AKG apps no longer work the same

Author
Message
Dale Schultz
3
Years of Service
User Offline
Joined: 1st Nov 2021
Location: Maine, USA
Posted: 19th Dec 2022 20:47
I have a number of Android apps build with AppGameKit that talk to other computers on my network using sockets.
One (A) I developed a few weeks ago and one (B) I have been working on this week.

Yesterday, my Android got a software update . It is now running Android 13 Build TQ1A.221205.011 on a Pixel 4a

Last night I built a new version of my AppGameKit app B and updated the copy on my phone.
I tested it, worked fine, exited. Tried to run it a second time - it hangs. Have to kill the app. After killing it, it again runs once, but hangs on the second run.
Rebuilt the app, installed it again same result.

I tried the AppGameKit app A which I have not changed since last week and it now also exhibits the same symptoms. Runs fine once, then second run hangs.

The thing that has changed is the Android OS.

I now need to start isolating what in my code is triggering the problem. Perhaps some socket being left open?

I thought I would post this as a heads up in case others are pulling their hair out wondering what is going on.

I have two other AppGameKit network apps using pretty much the same libraries, call them C and D. Those two both still work fine, for multiple runs. I need to see what is common to A & B and not in C & D.

Is anyone else running Android 13 Build TQ1A.221205.011?
If so, (and ONLY if so) are you having similar issues?

The author of this post has marked a post as an answer.

Go to answer

Derek Darkly
13
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 20th Dec 2022 00:43 Edited at: 20th Dec 2022 00:46
This post has been marked by the post author as the answer.
It's my understanding that you can't actually close an app from within your AppGameKit program, it only falls to the background. The user must close the app manually.
(Using the END command will result in a crash, at least in the reviewers' eyes)

What I've resorted to doing is minimizing the app when the user wants to exit, and when they re-engage the window have it return to the main menu.
Send your parents to noisy sprite demo hell... enter the D-Zone
Dale Schultz
3
Years of Service
User Offline
Joined: 1st Nov 2021
Location: Maine, USA
Posted: 20th Dec 2022 00:56 Edited at: 20th Dec 2022 03:52
well something did change, we suspect a subtle change to how the Android keyboard gets activated, but the real cuprit was the 'end' command.

Yes, I got bitten by this:
https://forum.thegamecreators.com/thread/227351

Here is why...

In my main loop I call the socket handler, which handles getting a connection and passing incoming data off to be parsed and dealt with.
If there is no IP address, it asks the user for an IP address.

Some weeks ago I noticed that after ending my program, the socket on the other side was still open. I checked my code and decided that even after closing the connection, and terminating , the socket handler managed to reconnect. I thought that somehow the main loop was running, so in my termination code I simply cleared the IP address, so that it could not connect again. This all seemed to work until the Android change this week.

After my son and I dug into what was going on, he found the forum post above, and we learned that the 'end' command, on Android, no longer does what we thought it did. It minimizes the program and pauses it. It does not terminate the program on Android. So what was happening was the socket handler was about to prompt for the IP address, when the program got paused. When we 'launched' the program again, it was not in fact starting the program, it was just resuming the existing one, and for some reason the keyboard was not being activated like before. This is probably due to a subtle timing issue, something happens a bit faster or a bit slower than before, and without the keyboard activation, nothing could be entered into the IP prompt and the app was effectively hung.

Once we found out that 'end' only pauses execution, this explained why the connection was being remade weeks ago and what was going on.

When I am no longer using my app on the Android phone, I don't want it to keep a the TCPIP connection open, as I am often connecting to small ESP8266 processors where I am limited to just 4 connections. So we now disconnect when we are minimized and then auto connect again when we are activated. Here is our new function to handle this:



Since we needed to know if the code was running on Android and not Windows, we wanted to know what platform we are on. Sadly the documentation for the function GetDevicePlatform() states that everything will return a zero except an Amazon device which will return a 1. It is therefore pretty much useless to determine the platform. So we looked at GetDeviceType(), sadly what that does is return the version of whatever OS is being used and the values are open ended so we would have to maintain list of versions and hope that Windows and Android never get to to have overlapping versions. Then we found a function that has not been implemented on Windows....

GetDeviceNetworkType() will return -1 on Windows so we use that to know if we are on Windows. This is kind of kludgy as it relies on AppGameKit not implementing it on Windows.

Understanding that 'end' does not end allowed us to get back to an app that gets paused and continues again when used again! What a learning experience.

TL;DR;

end does not (Doc need to be updated)
No good function to determine OS type see GetDeviceBaseName()
Dale Schultz
3
Years of Service
User Offline
Joined: 1st Nov 2021
Location: Maine, USA
Posted: 20th Dec 2022 00:58
yes Derek Darkly's answer is spot on and came through while I was composing my summary!
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Dale Schultz
3
Years of Service
User Offline
Joined: 1st Nov 2021
Location: Maine, USA
Posted: 20th Dec 2022 03:52
Thanks Virtual Nomad! We did not find that, and it does what we needed! GetDeviceBaseName()

Login to post a reply

Server time is: 2024-11-21 12:31:11
Your offset time is: 2024-11-21 12:31:11