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

[WSA] Saving state when quitting windows store app?

Discussion in 'Editor & General Support' started by Foriero, Aug 6, 2017.

  1. Foriero

    Foriero

    Joined:
    Jan 24, 2012
    Posts:
    584
    Hello, we are facing saving issues that when the app is closed our state of the game is not saved. The problem with wsa apps is that if users close them first windows calls suspend app and then it kills it in 5s limit. Those 5s we have time to save our data. So my question is how we can use this time to save our game data? Normally all background threads from thread pools are killed immediately without notifying anyone. If one wants to get notified he needs to write BackgroundTask and call deferral.Complete()

    Any solution for this saving issue? How does unity solved this problem for PlayerPrefs? Can we have source code example for that?

    Thank you.
     
    Last edited: Aug 6, 2017
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,589
    In which Unity beta version do you face this issue? Did this work in earlier versions?
     
  3. Foriero

    Foriero

    Joined:
    Jan 24, 2012
    Posts:
    584
    Well it never worked. We actually using EasySave2 on separate saving thread. Unity faced the same problem with their PlayerPrefs but since they are synchronous it was causing us glitters in graphics. So we decided that we rewrite our own implementation of PlayerPrefs based on EasySave2. On other platforms we don't have any issue with saving state on other thread since we can finish that thread just by setting internall terminate bool into false and thread.Join wait for that thread. But WSA does not have any thread.Join. :-( I would be really happy if we can find a solution how to have background saving thread that is exited correctly when app exits ( or suspend ). We can alway resume or reinit that thread OnResume. Any idea?