/ Forums
Applications are now open to attend this year's Oculus Connect. Join us October 11–12 and be first in line for an inside look at what’s new and next for VR.

Oculus Connect 4: Speaker Preview

We've revealed some of the Oculus speakers who'll present at Oculus Connect 4 this year! Click here to learn more.
New To The Forum? Click Here To Read The How To Guide. -- Developers Click Here.

Is it safe to call CloudStorage.Save in OnApplicationQuit?

AlanLiuAlanLiu Posts: 6
Virtual Boy (or Girl)
I'm using Unity engine with Oculus Platform SDK. And I'm curious about if I call CloudStorage.Save in OnApplicationQuit, then exit game immediately, can cloud storage be updated correctly?


  • imperativityimperativity Posts: 1,192 Oculus Staff

    Welcome to the Oculus Developer Forums.

    Based on how this is called and processed on our system, this would not save correctly as `CloudStorage.Save` and `CloudStorage.Load` are of type `Request<>`. They both have a method called "OnComplete", which takes a delegate (or a callback) to be executed once the request has finished.

    Since you would be quitting immediately after calling this, you would not get the necessary call back on completion.
  • AlanLiuAlanLiu Posts: 6
    Virtual Boy (or Girl)
    Thank you for the reply. If I'm not concerned about the completion callback(result), can I quit the game immediately after calling Save? I want to do this, because I observed that waiting for saving cloud storage may cost dozens of seconds when quit the game.
  • imperativityimperativity Posts: 1,192 Oculus Staff

    From the documentation:

    The following SDK methods can be called from your client app:

    • Save a blob:

      Native - ovr_CloudStorage_Save()

      Unity - Platform.CloudStorage.Save()

      Data is stored as an opaque binary blob, review the ovr_CloudStorage_Save page for information about the parameters and return data structure.

      This call sends the blob data to the locally running Oculus process and will not trigger network calls. Network synchronization happens when the App is no longer running. Total size for a blob can not exceed 10Mb.

      Note: It is important, when sending a cloud save, that a local copy of the data is maintained until confirmation is received that the cloud save was successful. If an error occurs, the data contained in the request will be lost and you'll need to try again.
    Basically, yes---you can do this, but there is a chance that quitting before confirmation will result in your data being lost. Proceed at your own risk.
  • AlanLiuAlanLiu Posts: 6
    Virtual Boy (or Girl)
    OK, I see. Thank you for your help.
Sign In or Register to comment.