Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unpackaged Windows App SDK app doesn't run on RS5/19H1 #1681

Merged
merged 7 commits into from
Nov 1, 2021

Conversation

DrusTheAxe
Copy link
Member

@DrusTheAxe DrusTheAxe commented Oct 29, 2021

https://task.ms/36777674

The bootstrapper relies on AppExtension to enumerate candidate DDLMs for the specified criteria. However AppExtension.Find*(name) only matches packages on <=19H1 if the caller is packaged and declares a matching AppExtensionHost (this must-have-matching-AppExtensionHost requirement was removed in 20H1). Since unpackaged apps have no appxmanifest.xml to declare an AppExtensionHost MddBootstrapInitalize() fails on RS5+19H1.

Bootstrap implementation is altered to workaround this AppExtension/RS5+19H1 limitation. The spec will be updated but here's the synopsis

  1. Bootstrap enumerates potential DDLMs via PackageManager.FindsPackagesByPackageType(framework) instead of AppExtension.OpenCatalog(ddlm)
  2. Bootstrap uses a DesktopBridge application process (DynamicDependencyLifetimeManagerShadow.exe) instead of a PackagedCOM OOP Server to inform Deployment the WinAppSDK Framework package-in-use
  3. the package-in-use process quits when...

...it's told to quit via an named event (i.e. MddBootstrapShutdown signals to it)
or
...the caller process terminated (w/o calling MddBootstrapShutdown) instead of last COM reference to the PackagedCOM OOP Server was Release'd
DDLMshadow waits on the named event (signal from MddBootstrapInitialize) and caller process handle (OpenProcess) and quits when either pops.

MddBootstrapInitalize() activates the DDLMshadow app with arguments including the caller's process id (so DDLMshadow can get a handle to the process) and a unique id (to ensure the caller process hasn't quit and processid reused for a new process before DDLMshadow uses it).

This results in N DDLM processes (1 per Bootstrap-calling process) instead of 1 DDLM process (the PackagedCOM
OOP Server for all Bootstrap-calling processes). IOW the DDLMshadow app process is multi-instanced vs DDLM PackagedCOM process is single-instanced.

NOTE: Parts of this will be used to address the elevation issue (#567). More is needed to solve that but this work isn't entirely just-for-downlevel :-)

This "DDLMviaEnumeration" codepath is used instead of the DDLMviaAppExtension when running on <=19H1 -or- the environment variable MICROSOFT_WINDOWSAPPRUNTIME_DDLM_ENUMERATION exists (e.g. set MICROSOFT_WINDOWSAPPRUNTIME_DDLM_ENUMERATION=1). The latter was used to verify same net behavior on >19H1 despite different implementation.

All related UnitTests pass as expected.

Additional E2E tests are being added in the aggregator as a separate PR.

NOTE: This change requires the aggregator be updated adding a file to DDLM MSIX packages named Microsoft.WindowsAppRuntime.Release=<rmajor>.<rminor>.<rpatch> specifying the release version (e.g. 1.0.0). This is necessary as the MSIX package versioning scheme currently does not specify the rmajor in the package's identity. This was handled via AppExtension but lacking that is only available if we "Find, Load and Parse appxmanifest.xml" at runtime <shudder>. This file let's use much more efficiently determine the release major version, necessary so we match the expected release e.g. so `MddBootstrapInitialize(0x00010002,...) doesn't match 0.2., 2.2., ...

…otstrap enumerates potential DDLMs via PackageManager.FindsPackagesByPackageType(framework) instead of AppExtension.OpenCatalog(ddlm), 2) Bootstrap uses a DesktopBridge application process instead of a PackagedCOM OOP Server to indicate WinAppSDK Framework package-in-use, and 3) the package-in-use process quits when it's told to (because MddBootstrapShutdown was called) or the caller process terminated (w/o calling MddBootstrapShutdown) instead of last COM reference to the PackagedCOM OOP Server was Release'd. We now get N 'shadow' processes (1 per Bootstrap-calling process) instead of 1 process (1 PackagedCOM OOP Server for all Bootstrap-calling processes), but the DDLMShadow process is small and cheap. Single-instancing DDLMShadow.exe is an exercise for the future (assuming it's not obsolete and dropped). NOTE: Still has some debugging code pending testing. At least 1 more commit to come...
@riverar
Copy link
Contributor

riverar commented Oct 29, 2021

Sounds like this is also related to #1121

@DrusTheAxe
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DrusTheAxe
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DrusTheAxe
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DrusTheAxe
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DrusTheAxe
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DrusTheAxe
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DrusTheAxe DrusTheAxe enabled auto-merge (squash) November 1, 2021 21:44
@DrusTheAxe DrusTheAxe merged commit d7b2e03 into main Nov 1, 2021
@DrusTheAxe DrusTheAxe deleted the user/drustheaxe/findddlm branch November 1, 2021 22:17
@DrusTheAxe
Copy link
Member Author

P.S. The PR's titled RS5/19H1 but the problem's also on 19H2 i.e. Windows <20H1 is affected

DrusTheAxe added a commit that referenced this pull request Nov 3, 2021
Non-AppExtension implementation for <=19H1

Altered Bootstrap to workaround AppExtension issue on RS5+19H1:

1) Bootstrap enumerates potential DDLMs via PackageManager.FindsPackagesByPackageType(framework) instead of AppExtension.OpenCatalog(ddlm)

2) Bootstrap uses a DesktopBridge application process instead of a PackagedCOM OOP Server to indicate WinAppSDK Framework package-in-use

3) the package-in-use process quits when it's told to (because MddBootstrapShutdown was called) or the caller process terminated (w/o calling MddBootstrapShutdown) instead of last COM reference to the PackagedCOM OOP Server was Release'd.

We now get N 'shadow' processes (1 per Bootstrap-calling process) instead of 1 process (1 PackagedCOM OOP Server for all Bootstrap-calling processes), but the DDLMShadow process is small and cheap. Single-instancing DDLMShadow.exe is an exercise for the future (assuming it's not obsolete and dropped).

Added/relies-on a 'release marker' file in the DDLM package to identify the major.minor release (required as otherwise few options to determine the major, none of them cheap).
DrusTheAxe added a commit that referenced this pull request Nov 3, 2021
…19h1

Unpackaged Windows App SDK app doesn't run on RS5/19H1 (#1681)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WAS runtime cannot be found/loaded by apps on Windows Server 2019 LTSC
6 participants