locked
Loading data on app activation RRS feed

  • Question

  • My application on activation has to load data by calling about 10 different URLs using WinJS.xhr. Unfortunately when testing the application on slow network the application crashes with the message "App did not launch within its allotted time".

    It is a Grid app starting from the relevant Visual Studio sample using a PageControlNavigator. The grid on the first level (when application starts) is filled from the values returned from the web services calls.

    I tried using the Extended Splash Screen sample but unfortunately (maybe I do something wrong) I keep getting the above error.

    In the default.js activated event I have this part of code

    splash = args.detail.splashScreen;
                SdkSample.coordinates = splash.imageLocation;
                splash.addEventListener("dismissed", onSplashScreenDismissed, false);
                ExtendedSplash.show(splash);
                Data.gen();
                window.addEventListener("resize", onResize, false);

    which initiates the extended splash screen.

    The Data.gen() is a function call inside data.js which does the call to the webservices.

    The default.html is like below where the contenthost exists and after activation the application navigates to the groupedItems.html page.

    <body>    
        <div id="extendedSplashScreen" class="extendedSplashScreen hidden">
            <img id="extendedSplashImage" src="/images/splashscreen.png" alt="Splash screen image" />                        
            <div id="extendedSplashDescription">
                <span id="extendedSplashText">Please wait</span>
                <br /><br />
                <progress id="extendedSplashProgress" style="color: white;" class="win-medium win-ring"></progress>            
            </div>
        </div>
        <div id="contenthost" data-win-control="Application.PageControlNavigator" data-win-options="{home: '/pages/groupedItems/groupedItems.html'}"></div>
        <!-- <div id="appbar" data-win-control="WinJS.UI.AppBar">
            <button data-win-control="WinJS.UI.AppBarCommand" data-win-options="{id:'cmd', label:'Command', icon:'placeholder'}" type="button"></button>
        </div> -->    
    </body>

    In groupedItems.html the binding process is being done as shown in the samples on MSDN.

    I tried calling Data.gen() in ready status of the groupedItems.js but nothing changed. Since the application enters the ready status in the landing page (groupedItems.html) isn't it concerned activated (so it does not have the 15seconds limit)? Either way if Data.gen() is being called there I keep getting the error.

    I'd appreciate if somebody helps me with that case since the application is fully operational except from the case when network is slow and it takes a lit of bit more to load.


    • Edited by darko9 Friday, August 31, 2012 9:24 AM
    Friday, August 31, 2012 9:23 AM

Answers

  • Do this:

    I assume you are familiar with the Splash Screen example.  Make the first screen in your application something that looks like your splash screen and put a progress ring on it (see the weather app).

    In your launch code, allow the app to start normally (don't put any code to get your data) except, let that spash screen activate!  Don't grab your data in the activate handler.

    Call setImmediate() for your data fetch and in the completion of that data fetch you can navigate to (or show) your normal first screen: http://msdn.microsoft.com/en-us/library/windows/apps/hh453394.aspx

    -Jeff


    Jeff Sanders (MSFT)

    Friday, August 31, 2012 6:22 PM
    Moderator