none
[UWP][HTML] WACK - App Prelaunch test fail RRS feed

  • Question

  • Hi,

    I'm having a problem getting my application to pass the tests in the WACK tool. It fails on the App prelaunch test.

    Reading the documentation on: https://msdn.microsoft.com/en-us/library/windows/apps/mt593297.aspx and it mentions the following:

    "Tip  If you wish to opt-out of prelaunch, check the LaunchActivatedEventArgs.PrelaunchActivated flag. If it is set, return from OnLaunched() before doing any work to create a frame or activate the window."

    I'm developing in JavaScript (TypeScript to be more precise) so I tried to handle the event by doing the following:

        app.onactivated = function (args: ICustomEvent) {
            if (args.detail.prelaunchActivated) {
            }
        }

    But it still complains.

    What's the best way to handle  the event in a way that passes the WACK test?

    Thank you,

    Ricardo.


    Ricardo Sabino --- http://www.ricardosabino.com

    Monday, December 28, 2015 5:14 AM

Answers

All replies

  • I'm running into a similar issue with a C# application. Did you ever happen to figure this out?

    • Proposed as answer by djchacal Friday, July 22, 2016 9:43 PM
    Wednesday, December 30, 2015 2:03 AM
  • Have you updated the "Windows app certification kit" to the latest version?

    The latest version is: 10.0

    https://dev.windows.com/en-us/develop/app-certification-kit 


    Hope that helps.

    Wednesday, December 30, 2015 9:30 AM
  • Didn't fix the issue yet. I do have WACK 10.0.

    Ricardo Sabino --- http://www.ricardosabino.com

    Wednesday, December 30, 2015 4:40 PM
  • Yep, same here. I'm running WACK 10.0. I've tried multiple things suggested in the link Ricardo posted in the original question, but with no luck. I've tried to opt out of pre-launch by having an 

    if(e.PrelaunchActivated) {
        return;
    }

    at the top of the OnLaunched method. No luck :(

    My OnLaunched method as of now is below, almost word for word what is shown in the Prelaunch example except for the debugger statement at the top which should be taken out when the package is built for release: 

    protected override void OnLaunched(LaunchActivatedEventArgs e)
            {
    
    #if DEBUG
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    this.DebugSettings.EnableFrameRateCounter = true;
                }
    #endif
    
                Frame rootFrame = Window.Current.Content as Frame;
    
                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (rootFrame == null)
                {
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame = new Frame();
    
                    rootFrame.NavigationFailed += OnNavigationFailed;
    
                    if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                    {
                        //TODO: Load state from previously suspended application
                    }
    
                    if (!e.PrelaunchActivated)
                    {
                        //do nothing...
                    }
    
                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;
                }
    
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }

    I've also changed the constructor of the MainPage so that it only runs "this.InitializeComponent()" and registers for the ViewChanged event (as is suggested in the link above).

    Is there anything that I've missed? A couple of thoughts that I have:

    1) Since I have nothing in the "if (!e.PrelaunchActivated)" statement, is it optimized out? I've tried the WACK tests with code in this statement, but with no luck.

    2) Is this a timing issue? Does the WACK test fail because the application is taking too long to suspend, or does it not recognize that I'm handling the prelaunch.

    I've been banging my head over this for the past couple of days, so any and all suggestions are greatly appreciated.

    Thanks.

    Wednesday, December 30, 2015 6:16 PM
  • Hey Ricardo,

    Try running the WACK tests on a different machine. I don't know if you are developing on a Windows Insider version, but I ran the same exact application on a stable version of Windows 10 and everything turned out fine.


    Wednesday, December 30, 2015 10:27 PM
  • Thanks! I'm running a Windows Insider version. I'll try what you suggested. Thanks again!

    Ricardo Sabino --- http://www.ricardosabino.com

    Wednesday, December 30, 2015 10:35 PM
  • This is probably it. There's a known issue being tracked regarding WACK failures and Prelaunch on preview builds.
    Wednesday, December 30, 2015 11:15 PM
  • Hi, I am having the same problem with VS2015 update 1.  I am not running Windows Insider version. I am able to simulate it with a blank app project and then immediately creating an app package and app certification.

    Thursday, January 7, 2016 7:55 AM
  • "Tip  If you wish to opt-out of prelaunch, check the LaunchActivatedEventArgs.PrelaunchActivated flag. If it is set, return from OnLaunched() before doing any work to create a frame or activate the window."

    I'm developing in JavaScript (TypeScript to be more precise) so I tried to handle the event by doing the following:

        app.onactivated = function (args: ICustomEvent) {
            if (args.detail.prelaunchActivated) {
            }
        }


    That "tip" is for XAML apps. It doesn't make sense for HTML apps, as you don't get the option to activate a window or not (the WWAHost infrastructure does this for you).

    So your code there isn't opting out of prelaunch at all. You're just happily doing nothing during prelaunch, which probably isn't going to generate the experience you want.

    Instead, I suspect the right way to "opt out" of prelaunch is to just call window.close(). I don't know what the WACK will do with this though. Further, why are you opting out?

    Saturday, February 20, 2016 8:37 PM
  • To be honest I didn't want to opt out,  I just wanted to fix the fail test reported by the WACK tool. The code was an attempt to opt-out and bypass the test on WACK but like you said it obviously failed to do that.

    Ricardo Sabino --- http://www.ricardosabino.com

    Sunday, February 21, 2016 12:27 AM