We recently created an app that downloads an assetbundle on firsh launch and stores it in Application.persistentDataPath. Apple rejected it because that data is backed up on iCloud.
In that link, it specifies that data that is required for offline play must be marked “do not backup”. I don’t recall ever seeing this option in Unity, so is there a manual way to do so in Unity?
This would be a problem for anyone using assetbundles as a one time storage and not storing them in the cache.
Before suggesting this, we’ve tried storing the asset bundle in the cache. However, it swelled to 100mb +. Storing it out side the cache let it remain the initial 2.7mb. I’ve also seen some discussion where storing in the cache is not recommended because that is the first place iOs begins to trim down data when it gets low on storage.
If the data is marked as do not backup does that mean that if a person downloads an asset bundle for an in app purchase, that itunes will not back it up when it is synced? If so how does a person recover an in app purchase if their phone has to be restored?
Just as a clarification, and I realize this might be a dumb question, but:
the parameter path of iPhone.SetNoBackupFlag() is the name of the asset bundle file, right? For example: “samplebundle.unity3d” ? The reason I ask is because I can pass that as the parameter for something like Caching.IsVersionCached(url, version), and receive feedback, but I can’t check if the iPhone.SetNoBackupFlag(path) is being set correctly on my assetbundle.
WWW.LoadFromCacheOrDownload always sets “No Backup” flag for cached files. If you are caching files manually and storing them via .NET file API then you should set this flag from your code by calling iPhone.SetNoBackupFlag() and passing full path as an argument.
@Mantas-Puida We have a build which has been rejected by Apple. The asset bundle handling code did not change in this update, and we always used www.LoadFromCacheOrDownload. In fact the current live build which was built with 5.3.2p3 works fine (only 250k is being reported in iCloud storage from Settings app). The rejected build was done with Unity 5.3.3p1 which is trying to backup any downloaded asset bundles. The same erroneous behaviour is also present in builds done with 5.3.3p2.
Do we need to do something from our side, as from 5.3.3, to flag asset bundles to not be backed up?
@JoshPeterson Tagging you since this might be in your realm of IL2CPP team
Hello @xenonmiii ,
The fix will be coming next week in 5.3.4p1. For now you can modify FileSystem.mm to always set the no backup flag:
extern "C" int UnityUpdateNoBackupFlag(const char* path, int setFlag)
{
int result;
if (true) // if(setFlag)
{
u_int8_t b = 1;
result = ::setxattr(path, "com.apple.MobileBackup", &b, 1, 0, 0);
}
else
{
result = ::removexattr(path, "com.apple.MobileBackup", 0);
}
return result == 0 ? 1 : 0;
}
This will make sure any asset bundles that are downloaded are flagged to not be backed up to iCloud. Let me know if you have any issues or further questions.
Cheers,
Chris
edit: I erroneously put 5.3.3p4 as the patch release when I first posted
Hey @mantikor ,
The fix has made it’s way to 5.3. It is still slowly making it’s way into 5.4. I will poke this thread once it has landed.
Thanks,
Chris