carp.sensing-flutter icon indicating copy to clipboard operation
carp.sensing-flutter copied to clipboard

All app files gone on iOS

Open sc00n opened this issue 4 years ago • 5 comments

On almost all our iOS participants we had an issue that after a while of mobile sensing all the app related files (in NSDocumentDirectory on iOS) were gone (removed). As this does not happen to our app when mobile sensing is turned off I suspect it has something to do with the sensing.

I don't think that there is anything wrong with the CARP code that causes this. I just want to warn the community that this might happen and see if anybody else encountered this problem. We suspect however that it has something to do with gathering a big chunk of data and saving many files with sensing data on the phone.

We now implemented two fixes which seem (until now, fingers crossed) to solve the problem:

  1. We make sure all mobile sensing files are uploaded regularly and deleted afterwards. Even if there is no Wifi. We think the problem might be caused by some storage issue. Uploading and deleting the files often may solve this.
  2. Giving the most important files in the NSDocumentDirectory the key NSURLIsExcludedFromBackupKey. The reasoning here would be that some files are backed up and removed from the phone when too many files are written in the NSDocumentDirectory.

For now, we have no idea which of both solutions has helped :).

sc00n avatar Nov 08 '21 20:11 sc00n

Thanks for the heads-up. Once we have solved this issues, the solution might go to the wiki documentation where we assembles best practice advice.

  • https://github.com/cph-cachet/carp.sensing-flutter/wiki/5.-Best-Practice

bardram avatar Nov 10 '21 13:11 bardram

The file data backend allows for zipping files - in my experience, this reduces the json files with a factor 10. See

  • https://github.com/cph-cachet/carp.sensing-flutter/wiki/C.-Data-Backends#files

bardram avatar Nov 10 '21 13:11 bardram

Actually - I've long been considering to write a data backend using sqflite.

@sc00n - would this be something you could do as a PR?

bardram avatar Nov 13 '21 14:11 bardram

We already use zip the files.

We (koenniem and me) would be happy to help with PR's but I know little about databases, so I don't think this task is suited for us. Please let us know when you have something else in mind where we can help!

sc00n avatar Nov 16 '21 18:11 sc00n

I've implemented support for SQLite and it be part of the 0.40.0 release.

bardram avatar Jul 15 '22 17:07 bardram

Released with version 0.40.0.

bardram avatar Sep 25 '22 21:09 bardram