Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback Caching layer

Discussion in 'Cloud Save' started by DavidZobrist, Jan 10, 2022.

  1. DavidZobrist

    DavidZobrist

    Joined:
    Sep 3, 2017
    Posts:
    233
    Firebase and MongoDB Realms do localy store downloaded data (encrypted). In case the player has no internet connection, this bridges offline periods, in mobile games while traveling for example.
    This enables to players to play offline meanwhile and the failed requests are performed when the client gets connection to the internet again.

    Also they know when data has changed on the server ( if the fields become editable on the website for example, or through cloude code etc.), so when we perform the request there isnt one performed if nothing has changed to prevent unnecessary calls.

    Is anything like this already the case or planned for unity cloud save?
     
    rpuls likes this.
  2. Unity_AndyP

    Unity_AndyP

    Unity Technologies

    Joined:
    Jun 23, 2021
    Posts:
    65
    Currently, if a user is offline the SDK will return a CloudSaveExeption with the reason specified in it (in this case, it couldn't connect). You are able to implement a retry for sending this information again at any point whether that be in the current session or in future ones, in which case you will need to store it. As this product is still in Beta we are looking at ways to help make this easier in future updates.

    For the moment, we only store small pieces of data so checks haven't been implemented yet as no real optimization is needed. Going forward, as we continue to see the files get larger, we will be adding in those checks to see the differences in files and if they need to update.
     
    DavidZobrist likes this.
  3. DavidZobrist

    DavidZobrist

    Joined:
    Sep 3, 2017
    Posts:
    233
    Ok thanks for the answer :)
     
  4. DavidZobrist

    DavidZobrist

    Joined:
    Sep 3, 2017
    Posts:
    233
    @Unity_AndyP Hey Mate :)

    I just wanted to ask again for that caching layer.
    We are currently using MongoDB Realms for our customer registration / custom licensing model.

    https://www.psycurio.de/


    How ever I would really prefer to move over to cloud save ( its also ok in this case to write from the client).
    I would love to have all in unity :D

    How ever the major reason why we cant swtich yet is that there is no solution for using it offline.

    Mongo DB Realms has something like a local copy of the db on the client. And does re-sync when the client has internet again (all the details below i dont know). But it is reliable.

    Their api gets abit has a few hickups tough which maybe could be avoided aswell but they feel a bit convuluted on their side.

    Maybe unity can make this simpler.
     
  5. DavidZobrist

    DavidZobrist

    Joined:
    Sep 3, 2017
    Posts:
    233
    These points are a bit convuluted in Mongo DB Realms:

    Waeving db schemas:
    It auto weaves changes to the DB classes which you can define in the client. We have the developer mode always on so I dont have to go manually change them. How ever changing git branches can mess up those schemas.
    Unity is schemaless and this would never be a problem.

    Server to client callbacks:
    In Mongo DB you can subscribe on any field in the db. And the client can subscribe to change of this field.
    So we can update the license online for our customer standing in the vr googles while beeing in a direct call with us. And the customer gets the change immediately on field edit enter.
    Unity does not have that!!

    None transparent calls:
    Mongo DB has some points where it feels hacky.
    Leading back to the caching layer I assume. I would never build something like this myself that sounds very difficult.
    But maybe unity can help us with that.

    This is an example:

    Code (CSharp):
    1. if (canReachDB)
    2.         {
    3.             // App must be online for user to authenticate
    4.          //   Debug.Log("try with internet connect");
    5.             realmUser = await realmApp.LogInAsync(Credentials.Anonymous());
    6.             _devices = await Realm.GetInstanceAsync(new PartitionSyncConfiguration("partition", realmUser));
    7.             Debug.Log("Authenticated with id: " + realmUser.Id);
    8.         }
    9.         else
    10.         {
    11.             // This works whether online or offline
    12.          //   Debug.Log("try no internet");
    13.             realmUser = realmApp.CurrentUser;
    14.             _devices = Realm.GetInstance(new PartitionSyncConfiguration("partition", realmUser));
    15.         }
    They have an async and none async method to get the local instance or online instance.
    It feels somehow unreliant even if it does work under the hood.
    We also had random outcomes and a bug based on my missunderstanding of this code.
    I though why use both and deleted one option. And it didnt work offline anymore..
    And a follow bug later when subscribing to DB change came out if it aswell.

    And now I am here :D
    Hoping unity saves us all.

    Thanks,
    Dave
     
  6. DavidZobrist

    DavidZobrist

    Joined:
    Sep 3, 2017
    Posts:
    233
    btw. for the last issue I am very afraid that there is a hidden async call below the regular method.
    And I already thought about just for safety adding a wait frame yield.
    Not sure it would be required but I also dont wanna dig that deep into their code base..
    I trust unity there much more.
     
  7. DavidZobrist

    DavidZobrist

    Joined:
    Sep 3, 2017
    Posts:
    233
    So long.. (the idea is in my backlog..)

    upload_2023-1-18_13-52-31.png