[Bug] "TokenBroker" service keeps WinUI 3 app's process running after window is closed #4967
Labels
needs attention
Delete label after triage
public-client
untriaged
Do not delete. Needed for Automation
Library version used
4.64.0
.NET version
.NET 8
Scenario
PublicClient - desktop app
Is this a new or an existing app?
The app is in production, I haven't upgraded MSAL, but started seeing this issue
Issue description and reproduction steps
We have a WinUI 3 + .NET 8 based app which uses MSAL .Net for authentication. We came to notice that after an interactive login (account picker window shown) the app process will not exit after it is closed. With the "Analyze wait chain" option in Task Manager, it shows an svchost process is holding the app process, and this svchost process points to the "TokenBroker" service, which belongs to "Web Account Manager".
I've managed to reproduce it with the minimum code below. This issue seems to only reproduce when both of the following 2 conditions are met:
The code is also posted in this repo: aries-zhang/WinUI3-MSAL-Demo. Please follow these steps to reproduce:
This issue is really strange since it does not repro when there is not a WebView2 control in the app or the WebView2 control does not have a "Source" property set. I've also noticed with the same code it does not repro on Windows 10 (22H2).
It does not repro with silent login. It seems to have something to do with WAM + WebView2.
Also tried the older versions of MSAL .Net up to 4.52.0 and it still repros.
Relevant code snippets
Expected behavior
Expecting the app process should exit normally when closed.
Identity provider
Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)
Regression
No response
Solution and workarounds
No response
The text was updated successfully, but these errors were encountered: