yoyofr / modizer

iOS chiptune/module player
http://yoyofr.blogspot.com/p/modizer.html
138 stars 45 forks source link

Correctly update flags when entering background #19

Closed mistydemeo closed 12 years ago

mistydemeo commented 12 years ago

This fixes #13.

Modizer was often reporting that it had crashed, and was asking to reset settings, in situations where it had not actually crashed.

If an app enters background while still remaining active, then resigns active status, it's eligible to be closed by the OS at any time without explicit notice to the inactive app. This was happening to Modizer if it was doing background playback of a song, and then the playlist ended or the user paused playback. Modizer didn't explicitly save its settings or mark that it had exited cleanly if this happened.

So, if the user then opened other apps, and the OS closed Modizer to reclaim RAM, Modizer would assume it had crashed the next time it opened.

This patch adds explicit calls to saveSettings and updateFlagOnExit if applicationWillResignActive is called to help guard against this. I've done some light testing, and it does look like it fixed the issue - which should fix something that was bugging me a lot. ;)

mistydemeo commented 12 years ago

Steps to reproduce:

  1. Open Modizer and begin playing a song.
  2. Move Modizer to the background.
  3. Pause the song or allow the playlist to finish, without reopening Modizer.
  4. Open several other RAM-hungry apps, so that Modizer is killed by the OS to reclaim RAM.
  5. Reopen Modizer.

Original behaviour:

When Modizer is reopened, it will assume that it crashed and prompt the user to wipe their settings.

With this patch:

Modizer will reopen normally.