Quitting the app in Android freezes it
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Quitting the app in Android freezes it
Something is making my app freeze when I try to quit it. Either by directly calling the quit command, or by pressing the back key and passing the backKey handler. It just freezes and becomes unrensponsive. I am getting getting very frustated by this. My only option so far is just trapping the backKey message and do nothing. So the user has to quit it from the standard OS functions. Very annoying. Testing on Android arm64 with the minimum version set to 7.0 Nougat.
How could I debug the process of what's causing my app to hang? If I can't quit it, is there any command to hide/minimize/send to background the app?
Also I'm testing a more agressive routine to close Everything: pending messages, open sockests and so on... but still doesn't work. The app still freezes.
command quitMyProject
if the environment is "development" then exit quitMyProject
local tStacksInUse, tOpenStacks, tDontClose, tPendingMessages, tOpenSockets
lock messages
--Sockets
put the openSockets into tOpenSockets
repeat for each line mySocket in tOpenSockets
close socket mySocket
end repeat
--Messages
put the pendingMessages into tPendingMessages
repeat for each line myMsg in tPendingMessages
cancel item 1 of myMsg
end repeat
--Stop using stacks
put the stacksInUse into tStacksInUse
repeat for each line myStack in tStacksInUse
stop using stack myStack
end repeat
--Stacks
put the openStacks into tOpenStacks
put "message box,home,tool,Message Box,revTools,revMenubar" & comma & the short name of me into tDontClose
repeat for each line myStack in tOpenStacks
if myStack is not among the items of tDontClose then close stack myStack
end repeat
close me
quit
end quitMyProject
########END OF CODE generated by this livecode app: http://tinyurl.com/j8xf3xq ########
########Code tested with livecode 9.6.1########
How could I debug the process of what's causing my app to hang? If I can't quit it, is there any command to hide/minimize/send to background the app?
Also I'm testing a more agressive routine to close Everything: pending messages, open sockests and so on... but still doesn't work. The app still freezes.
command quitMyProject
if the environment is "development" then exit quitMyProject
local tStacksInUse, tOpenStacks, tDontClose, tPendingMessages, tOpenSockets
lock messages
--Sockets
put the openSockets into tOpenSockets
repeat for each line mySocket in tOpenSockets
close socket mySocket
end repeat
--Messages
put the pendingMessages into tPendingMessages
repeat for each line myMsg in tPendingMessages
cancel item 1 of myMsg
end repeat
--Stop using stacks
put the stacksInUse into tStacksInUse
repeat for each line myStack in tStacksInUse
stop using stack myStack
end repeat
--Stacks
put the openStacks into tOpenStacks
put "message box,home,tool,Message Box,revTools,revMenubar" & comma & the short name of me into tDontClose
repeat for each line myStack in tOpenStacks
if myStack is not among the items of tDontClose then close stack myStack
end repeat
close me
quit
end quitMyProject
########END OF CODE generated by this livecode app: http://tinyurl.com/j8xf3xq ########
########Code tested with livecode 9.6.1########
Monox
Developing a Cyber Physical System.
https://www.monoxware.com/
Developing a Cyber Physical System.
https://www.monoxware.com/
Re: Quitting the app in Android freezes it
Try removing all these lines:
I used to do all the cleanup like you do, but I stopped. Just issuing the quit command seems to take care of things with the possible exception of any open sockets that may be active. Try the quit command all by itself and see if that works. If so, you can selectively add in the other sections if necessary.
Except for the mainstack, none of those stacks are in a standalone, they only exist in the IDE. Actually, you don't need to close any stacks since quitting will do that for you, so you can remove that entire section. (BTW, "close" probably isn't what you want here, you probably want "delete".)put "message box,home,tool,Message Box,revTools,revMenubar" & comma & the short name of me into tDontClose
repeat for each line myStack in tOpenStacks
if myStack is not among the items of tDontClose then close stack myStack
end repeat
I used to do all the cleanup like you do, but I stopped. Just issuing the quit command seems to take care of things with the possible exception of any open sockets that may be active. Try the quit command all by itself and see if that works. If so, you can selectively add in the other sections if necessary.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Quitting the app in Android freezes it
This is the simplest form of quitting that I have tried. Putting this code at the mainstack script:
Once I open the app, exiting with the back button works with that code. As I navigate to others screen (e.g. Home) and then press back button to quit, the app freezes and stops responding. Doesn't properly quit. The code I posted was a more aggressive cleanup to try to determine what could be causing my app to hang. Even with canceling pending messages and closing opened Sockets, it still freezes/crashes.
I'm pretty certain that by the time I arrive back to Login Screen, I have already closed everything. Loops, sockets, and so on... I don't know what possibly could make the app fail to quit.
I don't know how to debug this process either.
Code: Select all
on backKey
quit
end backKey
I'm pretty certain that by the time I arrive back to Login Screen, I have already closed everything. Loops, sockets, and so on... I don't know what possibly could make the app fail to quit.
I don't know how to debug this process either.
Monox
Developing a Cyber Physical System.
https://www.monoxware.com/
Developing a Cyber Physical System.
https://www.monoxware.com/
Re: Quitting the app in Android freezes it
You can try getting the result after the quit command:
But I'm not sure the quit command actually gives a result. Another possibility is that stacks can't close if the handler is still running. To get around that:
But since LC does quit if you don't navigate the stack, I'm not sure that's the problem either. One more thing to try:
I don't know of any way to specifically put the app in the background, but if you pass the backKey command Android OS should take over and go back to the launcher.
Code: Select all
quit
answer the result
Code: Select all
on backKey
send "quit" to me in 1 millisecond
end backKey
Code: Select all
on backKey
send "quit" to me in 1 millisecond
exit to top
end backKey
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Quitting the app in Android freezes it
Thank you for all the suggestion but the problem persist. It was worth a try. Even passing the backKey and letting the Android OS handle it still causes it to freeze sometimes. For now I will just trap it and do nothing.
For now I want to finish making my Windows app compatible with Android. This is the last and only bug left. Later on I will start creating new stacks and testing what could be the root of the problem. Maybe it could be a bug. If I were developing and Android app from scratch probably I would have noticed earlier. But given that I have a lot of commands for Windows, it's possible one of those who aren't Android supported could randomly affect this behavior. Will find out later. If you know of some way of debugging this behavior, please let me know.
For now I want to finish making my Windows app compatible with Android. This is the last and only bug left. Later on I will start creating new stacks and testing what could be the root of the problem. Maybe it could be a bug. If I were developing and Android app from scratch probably I would have noticed earlier. But given that I have a lot of commands for Windows, it's possible one of those who aren't Android supported could randomly affect this behavior. Will find out later. If you know of some way of debugging this behavior, please let me know.
Monox
Developing a Cyber Physical System.
https://www.monoxware.com/
Developing a Cyber Physical System.
https://www.monoxware.com/
Re: Quitting the app in Android freezes it
Did you ever see any info in the result?
or:
You can also try remote debugging which is very useful. Set a breakpoint at the quit command, cable your phone to the computer, and follow these instructions:
https://lessons.livecode.com/m/4071/l/6 ... e-debugger
On Android remote debugging won't work until you turn on USB Debugging in the Developer section of the phone's Android Settings. If you don't see Developer settings, you'll need to do this: https://www.howtogeek.com/129728/how-to ... droid-4.2/
Code: Select all
quit
answer the result -- may be empty
Code: Select all
try
quit
catch tErr
answer tErr
end try
https://lessons.livecode.com/m/4071/l/6 ... e-debugger
On Android remote debugging won't work until you turn on USB Debugging in the Developer section of the phone's Android Settings. If you don't see Developer settings, you'll need to do this: https://www.howtogeek.com/129728/how-to ... droid-4.2/
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Quitting the app in Android freezes it
Hi Jacque, Thanks for all suggestions!
I can't use remote debugging because that's only for business license and I have Indy.
The answer the result and try catch were good ideas but the problem is worse than I expected. I think I found the culprit. It is the external tsNet. I tried the same suggestion with the tsNetClose right before quitting the app but instantly crashes even in the IDE. Because it crashes my IDE the same way my Android app dies without response, then I assume that when the app is quitting and LC is closing everything, somewhere when it starts closing tsNet it crashes. It doesn't show any debugging options.
So I went back and reviewed all my code where I'm calling this external and found out there were a couple handlers where I wasn't closing the connection. I have now ensured that all connections are properly closed with tsNetCloseConn command. This has greatly improved the quit process. Instead of always crashing, now it's 'once in a while'. I guess I still have to continue exploring if somehow connections are remaining open, I must be missing something...Anyway, it is stated in the documentation: tsNetClose - Closes all open connections and disables the tsNet external. Even if I had open connections when quitting, the engine should close them.
I can't use remote debugging because that's only for business license and I have Indy.
The answer the result and try catch were good ideas but the problem is worse than I expected. I think I found the culprit. It is the external tsNet. I tried the same suggestion with the tsNetClose right before quitting the app but instantly crashes even in the IDE. Because it crashes my IDE the same way my Android app dies without response, then I assume that when the app is quitting and LC is closing everything, somewhere when it starts closing tsNet it crashes. It doesn't show any debugging options.
Code: Select all
try
tsNetClose -- It makes both IDE and Android crash.
catch tError
answer tError
end try
Monox
Developing a Cyber Physical System.
https://www.monoxware.com/
Developing a Cyber Physical System.
https://www.monoxware.com/
Re: Quitting the app in Android freezes it
If it's crashing it needs a bug report. LC should never crash. https://quality.livecode.com
You may get a workaround when LC examines the problem. Or at least a fix.
You may get a workaround when LC examines the problem. Or at least a fix.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Quitting the app in Android freezes it
Sure. Report made: https://quality.livecode.com/show_bug.cgi?id=23076
Monox
Developing a Cyber Physical System.
https://www.monoxware.com/
Developing a Cyber Physical System.
https://www.monoxware.com/