5

I'm writing an iOS application for enterprise deployment. The use case is that it is meant to run in the foreground in kiosk / guided access mode on iPads, and it must never ever close for as long as the OS is running (the iPads will be mounted on a wall and plugged into a power source).

I've set the iPad to never go to the lock screen, and I've put in the necessary IdleTimerDisable code. I set up Guided Access to run the app, and off it goes.

Everything works like a charm during the day. I can leave the iPad sitting there all day with the app in the foreground and it behaves exactly as expected. However some time overnight, something causes the application to close and when I arrive to work in the morning, the iPad is sitting on the home screen.

I keep the iPad connected to my Mac with the console open, but examining the logs and the console output doesn't reveal anything out of the ordinary.

I also have exception handling and logging code in place, but reviewing those logs shows no exception is being thrown either.

The behavior is consistent: I can keep the app open all day without issue, but by the next morning it is closed. Sometimes I can re-launch the app with Guided Access running, and sometimes I get trapped with Guided Access on the home screen preventing me from re-launching the app and I have to force the iPad to reboot.

Question: Does iOS perform some kind of clean up overnight that would cause the application to exit like this, or is there some other explanation?

If the OS is closing the app, how can I get around that?

Pertinent information: I've developed the app in Xamarin. The app continuously polls a REST API, via background threads, for as long as the app is open. Also, the iPad the app is currently on is not jailbroken, but I can jailbreak it if I need to to get past this issue.

sheppe
  • 708
  • 5
  • 12
  • 3
    Have you investigated the possibility of a memory leak? The fact that the application is quitting around the same time each night could be an indication that it's gradually losing available memory throughout the day. At a certain point, iOS gives your app a warning to reduce memory usage and eventually quits it if the warning isn't heeded. – ndmeiri Jul 08 '15 at 23:08
  • The code is pretty clean and simple, but that's not a bad idea. Presumably, if that's the case the DidReceiveMemoryWarning event will be triggered. – sheppe Jul 08 '15 at 23:13
  • 1
    Correct. You can also use the `leaks` instrument to analyze your app's memory usage. (Just so you don't have to wait a whole day to determine if the system is giving your app a warning.) – ndmeiri Jul 08 '15 at 23:16
  • You say you've got "exception handling". Do you have [unhandled exception handling](http://codereview.stackexchange.com/q/56162/36366)? And are you logging in AppDelegate life cycle methods? There's a whole ton of AppDelegate app life cycle methods. Find out *how* the app is exiting. If the app is completely closing it out, it must go either through the UE handler or through [applicationWillTerminate:](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/#//apple_ref/occ/intfm/UIApplicationDelegate/applicationWillTerminate:) – nhgrif Jul 09 '15 at 00:11
  • @sheppe Any luck with `leaks`? – ndmeiri Jul 09 '15 at 06:45
  • Have you considered using Single App Mode instead of Guided Access? This requires MDM, but since you're in an enterprise environment that could work for you. – Sarah Elan Jul 09 '15 at 13:23
  • @ndmeiri I did profile it for a couple of runs, working through the application's different features, and there were no memory leaks revealed. – sheppe Jul 09 '15 at 16:13
  • @Sarah Elan, yes I have considered that, but I don't think that Guided Access is the problem. – sheppe Jul 09 '15 at 16:14
  • 1
    So, I came in this morning and lo', my app was still up and running. Here's what I did differently, and why. Going through all of the logs reveals that even though I am not running a debug version of the app on the iPad, opening the project in Visual Studio on my **Windows** PC was still causing an interaction with the iPad. At the end of the day, I exited VS and then quit out of the app on the iPad and restarted it. It's still running this morning, and I'll leave it up throughout the day. Seems like it may have been the dev tools messing with things, though. – sheppe Jul 09 '15 at 16:23
  • 1
    Those pesky dev tools! I'm glad you solved your problem :) – ndmeiri Jul 09 '15 at 16:31
  • @sheppe I am facing the same kind of problem. I have developed an app in xamarin forms. And using it in kiosk / guided access mode on iPads. In my case app was working fine in past 5-6 months, but from last month app closes by itself at any time. Probably 5-6 times in a day. Don't know what's the issue, I have tried to debug but can't find anything wrong, my app get close and de-attach from debug mode by itself. Can anyone please help me out? – Vivek Shah Jul 09 '18 at 09:51
  • @VivekShah: Thats the problem with iOS 12, have you found any solution?. Same thing happens with me, after updating ipad to iOS 12, after exactly 20 minutes, app goes to background. Not sure, whats the problem. – Mehul Thakkar May 06 '19 at 05:09
  • @MehulThakkar, It's working fine for me now. Just make sure that your device is up to date with latest OS. – Vivek Shah May 06 '19 at 11:08

0 Answers0