Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time stops when app is closed (in background) #8

Open
bschippers718 opened this issue Jun 17, 2016 · 3 comments
Open

Time stops when app is closed (in background) #8

bschippers718 opened this issue Jun 17, 2016 · 3 comments

Comments

@bschippers718
Copy link

Hi,

Love the app, thank you. I've been modifying it and I noticed distance updates even while the app is closed but time stops. I'm fairly new to IOS dev. Any ideas on how to get time to continue even while app is running in the background?

Thanks again.

@mluedke2
Copy link
Owner

Thanks Ben,

Glad you've found this helpful! I'm not really supporting this much anymore, so that might be a bug due to recent iOS changes. @vermont42 do you have any ideas?

Thanks,
Matt

@bschippers718
Copy link
Author

Thanks Matt, much appreciated.

Sent from my iPhone

On Jun 17, 2016, at 1:19 PM, Matt Luedke notifications@github.com wrote:

Thanks Ben,

Glad you've found this helpful! I'm not really supporting this much anymore, so that might be a bug due to recent iOS changes. @vermont42 do you have any ideas?

Thanks,
Matt


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@vermont42
Copy link
Contributor

vermont42 commented Jun 18, 2016

My app RaceRunner started as a Swift port of MoonRunner. I'm not sure what exactly would cause the behavior that Ben describes, but here is a brainDump on running in the background.

Ensure that the app has the background-audio and (more importantly) background-GPS entitlements. If it does not, iOS will sometimes suspend the app when it is in the background.

Usage of other apps while RaceRunner is in the background may result in didReceiveMemoryWarnings, which may result in iOS killing RaceRunner. I saw this happen when I was attempting to use RaceRunner to record the drive from Berkeley to Lake Tahoe. Round about hour three, iOS consistently killed RaceRunner. The 1 gig of RAM on my iPhone 6 apparently isn't enough.

There is a fix for this behavior in the latest version of RaceRunner, which is pending review. If a view controller receives a didReceiveMemoryWarning, the view controller tells LowMemoryHandler, which tells RunModel to save the progress of the run using Core Data. LowMemoryHandler also issues an audio warning that RaceRunner may be killed due to the RAM shortage. After relaunch, if a run was in progress, RaceRunner asks the user whether the user wants to resume the run or discard it.

Here is the source code for RaceRunner.

As an aside, if you are learning iOS development, you may want to check out the Swift port of Matt's tutorial about MoonRunner.

Update: I recently used RaceRunner to track the 50-minute drive from Berkeley to Menlo Park. Curiously, RaceRunner received a didReceiveMemoryWarning approximately five minutes into the drive, and then iOS killed RaceRunner. I relaunched RaceRunner and resumed tracking. There were no problems during the remaining 45 minutes. Conclusion: Weird stuff happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants