locked
Application restart behaviour different coming from desktop in WinJS W8.1 App RRS feed

  • Question

  • We've encountered a strange problem in the following case:

    The app reloads its content on starting / resuming, but if we terminate the application, go to desktop, go to modern UI, and then start the application, the old, 'cached' version will be "loaded". (case1)

    Given the fact that terminating the application and starting it again without moving to desktop in between, everything works as expected. (case2) We do not have any clue what causes the error.  + this worked / works running the app on Windows8.

    What we've tried so far:

    • registered to all possible event handlers -> won't fire coming via desktop->modernui->app
    • ===> eg. 'loaded' fires in case 2, but not in case 1

    I fear this might be a general problem?

    Tuesday, November 5, 2013 10:36 PM

Answers

  • I forgot a really important part of this:

    The swipe top-to-bottom will put an app into suspend mode *unless* the app is quickly relaunched.  In that case, the swipe causes the original process to terminate and then be relaunched.  If the app is suspended by swipe, then an intermediate process is run (such as desktop), the relaunch causes start from suspend, which does not reraise the event.

    I hope this clears up the confusion.

    Most of this information is in the documentation that Jeff pointed at earlier, but I admit that it's missing the part about quick reactivation. 

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, November 12, 2013 8:04 PM
    Moderator

All replies

  • No problem.  The lifecycle management of applications is different (by design).

    See: Application lifecycle (Windows Store apps) (Windows)‎ 


    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Wednesday, November 6, 2013 8:26 PM
    Moderator
  • Dumb question, but why?
    And how can I respond to eg. the loaded event on app launching for the second time, if the user was on the desktop after closing the application in his first session? => This just seems to be a lack of functionality?!

    I really can't see the point, why there is a difference between the two cases.

    Clarification is greatly appreciated!
    Thanks so far!

    Wednesday, November 6, 2013 9:21 PM
  • Can you clarify what you mean about closing the application?  Maybe I am confused by your terminology and how it relates to the Lifecycle?  Also, did you read the article I posted?  Does it deviate from the published behavior?

    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)


    Thursday, November 7, 2013 1:47 PM
    Moderator
  • I will describe both cases again more detailed:

    case1:

    1. The user opens the application for the first time, does some research and clicks around.
    2. The user fineshed and closes the application by swiping from the top to the bottom or ALT F4.
    3. Now the users starts doing something else in another application. He does not switch to desktop and stays in modern ui for the whole time.
    4. He reopens our application and the eg 'loaded'-event is fired => we reload data.

    case 2:

    1. The user opens the application for the first time, does some research and clicks around.
    2. The user fineshed and closes the application by swiping from the top to the bottom or ALT F4.
    3. Now the users starts doing something else and switches to desktop, opening explorer, or office.
    4. He reopens our application and the eg 'loaded'-event won't fire.

    We tried around a lot and were able to isolate the problem to these two cases.

    So my question is:
    Why does this happen?
    Do I have to respond differently to events if the user was on the desktop before?

    Best regards!

    Thursday, November 7, 2013 2:42 PM
  • Thanks for the clarification.

    Please read the documentation I gave you in the beginning.  The 'App Close' section describes this fully and even tells you how to get the previous functionality.  If you don't understand part of this or need further clarification please come back with a specific example and a sample where you have followed and implemented from this section so we can investigate further.

    Best Regards,

    Jeff


    Jeff Sanders (MSFT)

    @jsandersrocks - Windows Store Developer Solutions @WSDevSol
    Getting Started With Windows Azure Mobile Services development? Click here
    Getting Started With Windows Phone or Store app development? Click here
    My Team Blog: Windows Store & Phone Developer Solutions
    My Blog: Http Client Protocol Issues (and other fun stuff I support)

    Thursday, November 7, 2013 2:52 PM
    Moderator
  • Hey Jeff!
    First of all: thanks for your assistance!

    I've created a very small demo project to show you my problem:

    http://sdrv.ms/HDM5dX

    It'd be great if you install the application and test both cases. Pay attention to the "time" output and the loaded-MessageBox! It will show my main problem -> coming from the desktop to relaunch the app won't trigger onactivated/loaded. In contrast to that, they trigger without leaving modernui.

    Will the problem be solved if I enable Windows.UI.ViewManagement.ApplicationView.TerminateAppOnFinalViewClose

    ? If yes - how (and where) do I do that? I'm kinda confused.

    Thank you!


    • Edited by mpcreation Friday, November 8, 2013 10:19 PM
    Friday, November 8, 2013 10:12 PM
  • Hi,
         I ran your application and need to explain what you're seeing here:

    1) There is a difference between app suspension and termination.  Suspend means that the app state will persist between viewings, and termination means that the state is lost.

    2) Windows 8.1 has a change where alt-f4 and swipe from top-to-bottom are no longer the same action.  Swipe from top-to-bottom now results in app suspension but it also removes the app from the app-switching stack (swiping from left-to-right to change apps).  Alt-f4 still terminates the app.  In 8.0, swipe from top-to-bottom resulted in app termination.  In 8.1, you can swipe from top-to-almost-bottom, hold, then you'll see the app tile turn around, and then you proceed off screen to do a full termination.

    Knowing this information, I could not reproduce your scenario.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, November 12, 2013 5:52 PM
    Moderator
  • Thanks for pointing out those two different cases! Especially the difference between Alt F4 and just swiping!

    Nevertheless, given the user just swipes down to close the app (without holding at the bottom of the screen), I can see a difference between my two cases. I've made a video for you, hence my understanding of your explanations and my descriptions may be terrible! (00:35minutes++ there is the difference!)

    http://www.youtube.com/watch?v=0VSuI-5JMmE

    Does going to desktop in-between influences the app-cycle? - How in detail?

    Ps.: Trying my cases with Alt+F4 or swiping and waiting until the tile turns around, everything works as expected!

    Thanks again for the great support and the help to make me understand :)

    Tuesday, November 12, 2013 7:04 PM
  • I forgot a really important part of this:

    The swipe top-to-bottom will put an app into suspend mode *unless* the app is quickly relaunched.  In that case, the swipe causes the original process to terminate and then be relaunched.  If the app is suspended by swipe, then an intermediate process is run (such as desktop), the relaunch causes start from suspend, which does not reraise the event.

    I hope this clears up the confusion.

    Most of this information is in the documentation that Jeff pointed at earlier, but I admit that it's missing the part about quick reactivation. 

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, November 12, 2013 8:04 PM
    Moderator