Windows-XAML / Template10

Making Windows 10 apps great again
Apache License 2.0
1.41k stars 389 forks source link

Crash when PreLaunch is used #595

Closed pekspro closed 8 years ago

pekspro commented 8 years ago

The latest release causes a crash when PreLaunch is used. This is easy to replicate in the "Tiles (and Toast)" sample (probably all samples, but this is the one I tested).

• Launch this sample with Debug -> Other debug targets -> Debug Universal Windows App Launch. • In Lifecycle Events select Suspend. • Wait at least 10 seconds. • In Lifecycle Event select Resume. • A null reference exception will now occur in BootStraper.cs, because of OriginalActivatedArgs is null line 86:

if ((OriginalActivatedArgs as LaunchActivatedEventArgs).PrelaunchActivated)
gregstoll commented 8 years ago

I believe this problem is causing my app to fail the Prelaunch test in the Windows App Certification Kit.

JerryNixon commented 8 years ago

This if ((OriginalActivatedArgs as LaunchActivatedEventArgs)?.PrelaunchActivated ?? false) will be part of 1.1.4 when it is pushed to NuGet. It is already in GitHub. Perhaps you could verify?

gregstoll commented 8 years ago

I verified that my app no longer crashes with the steps above. Thanks!

JerryNixon commented 8 years ago

Great, I will update the pack soon.

pekspro commented 8 years ago

The crash is gone, but it still doesn’t behave correctly. You will get stuck in the splash screen when the app is resumed.

I also found line 109-100 in bootstrapper.cs probably would look like this:

DebugWrite($"Calling. Prelaunch {(OriginalActivatedArgs as     LaunchActivatedEventArgs)?.PrelaunchActivated ?? false}", caller: "OnSuspendingAsync");
await OnSuspendingAsync(s, e, (OriginalActivatedArgs as LaunchActivatedEventArgs)?.PrelaunchActivated ?? false);

In HambugerMenu.xaml.cs there is these line which I assume also will crash if OriginalActicatedArgs is null (if that’s possible, I’m not sure):

if (_navigationService.FrameFacade.BackStackDepth == 0
    && BootStrapper.Current.SplashFactory != null
    && BootStrapper.Current.OriginalActivatedArgs.PreviousExecutionState != Windows.ApplicationModel.Activation.ApplicationExecutionState.Terminated)

That said, this doesn't explain why you get stuck in the splash screen :-(.