On Jul 16, 2014, at 5:59 PM, Len Kawell <[email protected]> wrote:
> CBLReplication.h says "On iOS a replication will suspend itself when the app > goes into the background, and resume when the app is re-activated." But this > does not seem to happen with our app running on iOS 7. It's probably more accurate to say "...will suspend itself when the app is in the background and the OS tells it to stop...". > According to the log, the replicator keeps pulling documents from the server > even while the app is no longer active and it's in the background. In my > testing, it seems to keep going for at least 8 minutes. According to Xcode > it's using 30-50% CPU while in the background on WiFi, which might not be > what the user is expecting. It's playing by the rules, registering a background session and suspending when the OS calls it back and says it's time to stop. Eight minutes in the background is longer than I would expect it to get, but that's really the OS's decision. The OS was probably giving background apps more time than normal because the device was charging (via the USB cable connected to your Mac.) As a user, I prefer it if an app can keep doing its work in the background -- I don't like it when I'm held hostage by an app that's doing a lengthy task (like a download) but cancels it if I background it. Of course I also want my devices to have good battery life, though. But I assume the OS is doing a decent job balancing those goals. > I added my own code to our app delegate applicationWillResignActive method to > stop all of the replications by invoking CBLReplication stop. [I tried > setting CBLReplication.suspended = YES instead of invoking stop, but the > replication continued to run (probably because of the backgrounding code > resetting suspended).] Huh, that should work. The replicator won't set suspended=NO when it goes into the background; that only happens when it returns to the foreground. It's unpredictable whether your notification handler or the replicator's will get called first, but either way the replication should end up being suspended. > However, invoking stop sometimes results in the following error: > WARNING*** : CBL_Puller[https:...]: Unable to save remote checkpoint: Error > Domain=NSURLErrorDomain Code=-999 "The operation couldn't be completed. > (NSURLErrorDomain error -999.)" -999 is kCFURLErrorCancelled. Maybe the replicator was in the process of saving the checkpoint at the moment it was told to stop; stopping a replication cancels all of its in-flight NSURLConnections. --Jens -- You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/66C77220-21B1-41B2-9F5B-67171ABC1BAB%40couchbase.com. For more options, visit https://groups.google.com/d/optout.
