WP7 app crashes with frequent activation / deactivation

I noticed that if in a WP7 app I press the start key and then quickly return the back button to return to the app, and repeat these steps very quickly many times, the app crashes (it exits unexpectedly and cannot recover via the "Back" key). This happens on the device (never displayed on the emulator) and it takes 10-15 steps before closing the app. I am following Microsoft's best practices for saving / restoring my state. Also, all other apps I've tried this way crash too. However, some applications are much more difficult to kill than others. While experimenting with this stress test, I noticed that games

  • XNA is generally less robust than pure Silverlight applications.
  • The more data is saved or restored by the application, the less stable it is LI>
Unfortunately my XNA game has to save a lot of data during deactivation and it is quite easy to make it crash.

Does anyone know if this is a known issue or something else? I would appreciate any advice on how to make the game more stable if the issue is not completely resolved.

+3


source to share


2 answers


Regarding the idea that the problem might arise in the De / -Serialization process, you can do this:

    private IsolatedStorageSettings isosettings = IsolatedStorageSettings.ApplicationSettings;
    void Application_deactivated()
    {
        isosettings.Add("serialization_finished", false);//just add once, 
                    //after that use isosettings["serialization_finished"]
        //DO: save here your code into isostorage
        isosettings["serialization_finished"] = true;
    }
    void Application_activated()
    {
        while (!isosettings["serialization_finished"])
            Thread.Sleep(500);
        //DO: read you data from isostorage
    }

      

So, you are practically building an on / off switch to check the completion of the serialization process



Old:

Tombstoning has a Timelimit in which it must end (10 seconds). I assume you are giving him so many stones that at some point one instance of the application cannot complete the tomb in time. But this is just an assumption that the more you save = the faster to crash.

You can test this by measuring the time it takes to get the tombstone and write the data to isolated storage. When you analyze the data and make sure that the time for the tomb is increasing (up to 8-9 seconds) you can conclude that it must be time.

On the other hand, if the required time never increases and remains within a few seconds, you can safely conclude that this should not be a time problem.

+1


source


I found a workaround on how to make the application more stable. In fact, we don't want to save game data to isolated storage every time we deactivate. This was only necessary when the game state was changed. When my game is automatically paused upon activation, the state has not changed and I do not need to save my data again until the user resumes the game. Thus, data is stored in isolated storage only for the first deactivation. This approach helped a little, but not much. 20 iterations of the Start / Back key still make it go down.



+1


source







All Articles