WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

Restart API not working with unpackaged apps in 1.1.3

Open Balkoth opened this issue 2 years ago • 15 comments

Describe the bug

Official documents https://docs.microsoft.com/en-us/windows/apps/windows-app-sdk/stable-channel#app-lifecycle--restart mention this should work for packaged and unpackaged apps, but using Microsoft.Windows.AppLifecycle.AppInstance.Restart(""); as described here https://github.com/microsoft/WindowsAppSDK/blob/main/specs/AppLifecycle/Restart/restartApi.markdown#new-api just crashes the app.

Steps to reproduce the bug

Just use this sample to verify: TestRestartManager.zip

Expected behavior

No response

Screenshots

No response

NuGet package version

1.1.3

Packaging type

Unpackaged

Windows version

Windows 10 version 21H2 (19044, November 2021 Update)

IDE

Visual Studio 2022

Additional context

No response

Balkoth avatar Jul 27 '22 12:07 Balkoth

It just crashes the whole application without getting a chance to debug even with native debugging enabled and all exceptions checked.

Once <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained> is set on the project you get a file not found exception. Turns out that RestartAgent.exe is not distributed: image

Balkoth avatar Jul 27 '22 13:07 Balkoth

@Balkoth thanks for providing the feedback. We will take a look at the issue and keep you posted on the updates

kanismohammed avatar Aug 01 '22 17:08 kanismohammed

With Template Studio 5.2 using 1.1.3, Restart("") works fine for me for both packaged and unpackaged projects. I do see a failure though when switching to self-contained. I get FileNotFound exceptions from the API which I assume is referring to RestartAgent.exe that you shared above.

mikebattista avatar Aug 01 '22 21:08 mikebattista

https://task.ms/40728649

mikebattista avatar Aug 01 '22 22:08 mikebattista

I can not confirm your observations. The attached sample was created with Template Studio 5.2 and does not ever restart. I can not find any relevant information on how to diagnose why. Eventlog does not show anything related in the Application log nor the AppLocker log.

TSRestartManagerTest.zip

Balkoth avatar Aug 02 '22 07:08 Balkoth

My next guess would be that it's a downlevel problem since you're on 19044. @kanismohammed are these APIs supported downlevel?

mikebattista avatar Aug 02 '22 15:08 mikebattista

My next guess would be that it's a downlevel problem since you're on 19044. @kanismohammed are these APIs supported downlevel?

@dhoehna - Can you please take a look?

kanismohammed avatar Aug 02 '22 17:08 kanismohammed

It was already answered here: https://github.com/microsoft/WindowsAppSDK/issues/2792#issuecomment-1196793506

The restart agent isn't being included when WASDK is self-contained.

dhoehna avatar Aug 02 '22 17:08 dhoehna

I can work on getting the restart agent to deploy with everything else.

dhoehna avatar Aug 02 '22 17:08 dhoehna

Thanks. There are two issues though. The self-contained issue is one. It's also possible the Restart API doesn't work for unpackaged apps downlevel. We need to investigate.

mikebattista avatar Aug 02 '22 17:08 mikebattista

Is there some more investigation ongoing or will this just be buried like all other bug reports?

Balkoth avatar Aug 09 '22 19:08 Balkoth

I'm looking into it. Progress has been slow, that's all.

dhoehna avatar Aug 09 '22 19:08 dhoehna

Sorry for the gap in communication. I'm reporting in that I did find the root cause of the issue.

The root cause of the issue is in the OS code. More research is needed to figure out where a fix should go. Most likely Windows App SDK.

Again, sorry for the delay in communication. It took a bit longer than expected to hunt down this issue.

@mikebattista We might need to add internal hours to find a fix for this issue. @kanismohammed FYI.

dhoehna avatar Aug 29 '22 19:08 dhoehna

@dhoehna I've already filed https://task.ms/40728649. Do we need another bug?

mikebattista avatar Aug 29 '22 19:08 mikebattista

Alrighty. Updating this. Sorry it took so long. The bug was deeper than I though.

This is a platform issue in VB. The ACLs on the folder in Windows Apps is Low IL. What this means is, even if the parent app is medium-IL, any process made in the frameworks folder, for example, RestartAgent.exe, "...\windowsapps[Fwp]\RestartAgent.exe" is lowIL.

Since restartAgent.exe creates the same process that was restarted, and, new processes inherit the parent processes IL, that means, the new process is also LowIL.

Now I'll be talking with peeps to figure out "What do we do about this and how do we fix it."

Again, sorry this is taking so long. I'm still working on it though.

dhoehna avatar Sep 14 '22 18:09 dhoehna

The ACLs are being changed and should be serviced in February.

dhoehna avatar Oct 19 '22 16:10 dhoehna

Will this also be fixed for unpackaged applications with <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained> ?

Balkoth avatar Dec 14 '22 09:12 Balkoth

Has this been serviced?

Balkoth avatar Feb 27 '23 06:02 Balkoth

The ACLs are being changed and should be serviced in February.

Is this fixed? If so what needs to be updated on our ends?

appindus-ibiller avatar Mar 08 '23 18:03 appindus-ibiller

Sorry for the late reply. This change was serviced on February 2nd.

To get the correct ACLs for Windows App SDK please either

  1. Remove then add Windows App SDK, or
  2. Update Windows App SDK to a newer version.

Essentially the framework package needs to be removed, then installed.

dhoehna avatar Mar 08 '23 20:03 dhoehna

I'm currently looking into a way to verify the fix is on a system so I can let ya'll know if the patch is present.

dhoehna avatar Mar 08 '23 20:03 dhoehna

@dhoehna Thanks for the reply! This will work for self-contained as well? Will we need to upgrade to 1.3 preview/wait for stable? or Will the WASDK's Feb release 1.2.4 suffice?

appindus-ibiller avatar Mar 08 '23 21:03 appindus-ibiller

It is not fixed for self-contained apps as the original problem that RestartManager.exe is not distributed still persists.

Balkoth avatar Mar 09 '23 06:03 Balkoth

Still not fixed in 1.3.1

Balkoth avatar May 15 '23 07:05 Balkoth

Any update on this? I'm able to restart the C++ packaged app, but I'm unable to restart the unpackaged application.

SlavDeV1991 avatar Jul 20 '23 11:07 SlavDeV1991

Is there any update on this issue? I have WindowsAppSDK 1.3.230724000 installed, and the problem is still there. My app is also an unpackaged application with WindowsAppSDKSelfContained enabled. Thanks.

ivan-miracle avatar Jul 31 '23 13:07 ivan-miracle

It takes over one year and this issue is still there. Is that reasonable for WinUI team?

zhuxb711 avatar Aug 02 '23 01:08 zhuxb711

The issue with RestartAgent.exe not being included in selfcontained apps is fixed in 1.4 preview 2.

AdamBraden avatar Aug 17 '23 14:08 AdamBraden