You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
On WinUI 3 preview 3 for Desktop, when calling WebAuthenticationBroker.AuthenticateAsync, I get the following exception:
System.Runtime.InteropServices.COMException (0x800706BD): There are no remote procedure calls active on this thread. (0x800706BD) at WinRT.ExceptionHelpers.ThrowExceptionForHR(Int32 hr)
at ABI.Windows.Security.Authentication.Web.IWebAuthenticationBrokerStatics.global::Windows.Security.Authentication.Web.IWebAuthenticationBrokerStatics.AuthenticateAsync(WebAuthenticationOptions options, Uri requestUri, Uri callbackUri)
at Windows.Security.Authentication.Web.WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions options, Uri requestUri, Uri callbackUri)
This code previously worked in a UWP application without problems.
Steps to reproduce the bug
Call WebAuthenticationBroker.AuthenticateAsync
Example:
var result = await WebAuthenticationBroker.AuthenticateAsync(
WebAuthenticationOptions.None,
authorizeUri, redirectUri);
Expected behavior
I would expect the Microsoft authentication dialog to appear.
Version Info
NuGet package version:
[Microsoft.WinUI 3.0.0-preview3.201113.0]
Wim Bokkers (@wbokkers), thank you for bringing this to our attention. The best way you can help us is to file this in the feedback app. Once you've done that, please post the link here and I'll promote it to the right team for diagnosing & fixing. By filing in the feedback tool and collecting logs, you can help us better diagnose the issue.
Ben Kuhn (@BenJKuhn) When you suggest folks file bugs in Feedback Hub, please provide the category and sub-category, as the likelihood we get it right (and the right on-demand diagnostics get executed) is very low.
In this case it's not going to matter much. I'm going to promote it in our database and directly assign it to the right team as soon as I get a link to the feedback. I understand that it's not always easy to map some features to feedback hub categories.
In this case, "Developer platform" -> "API feedback" would be appropriate.
So taking a look at the "Developer platform" > "API Feedback" category/sub-category, I don't see any associated user-initiated feedback diagnostics. So that means there won't be any specific logs collected for this issue.
If I remember correctly, that API still requires a CoreWindow.
Chatting with the team that owns WebAuthenticationBroker that's likely the concern. The "Broker" was necessary in a UWP so the user could enter their credentials into a Window displayed by the platform, rather than into one under the app's control. The Window was inferred from the thread calling RequestAsync (recall that a CoreWindow lives on a specific thread that it owns) so the broker knew where to show itself on screen and other attribution information.
We're discussing options for how to support people who were building UWPs with CoreWindow but are now investigating Project Reunion WinUI3 apps on Desktop Bridge. This category of problem - APIs that implicitly or explicitly need a CoreWindow - is high on our list to address (hi AdamBr (@AdamBraden) !).
Question for the thread - would you want a 1:1 replacement of WebAuthenticationBroker in Project Reunion that launched the browser for authentication then redirected back to the app? Or would you just want a Really Good Sample of how to register a protocol for your Win32 app and then use it from your authentication experience?
For reference by OS team, the Windows work item number is 31649739. I left a back-pointer in the workitem to here as well.
Rafael Rivera (@riverar), for what it's worth, even the general diagnostics provide a number of ETW data providers that can be helpful in debugging API failures. It's not as nice as having a scenario-tailored log, but it's not an empty data set either.
Question for the thread - would you want a 1:1 replacement of WebAuthenticationBroker in Project Reunion that launched the browser for authentication then redirected back to the app? Or would you just want a Really Good Sample of how to register a protocol for your Win32 app and then use it from your authentication experience?
I would prefer for Microsoft to continue owning that experience. Writing all that OAuth2 goop correctly can be tough and presents quite a hurdle for developers wishing to just access some token-required services. Having a single implementation would also maintain the consistency WebAuthenticationBroker sought to provide.
This is also a duplicate of issue #366. This is a known gap in platform support that is being looked at and tracked as an OS bug. A potential outcome of that might be that we consider addressing it as a new API in reunion. There are pro's and con's to both approaches. The specific crash in the specific API wouldn't be fixed as a Project Reunion bug though.
Ben Kuhn (@BenJKuhn) Given Reunion's goal of unifying access to existing Win32 and UWP APIs, it seems more appropriate to leave this (or the original) issue open, with a reference to the OS bug number, to track its progress.
Or perhaps this should be transferred to the Discussions area, as an Idea?
We've been carrying a lot of issues over to the OS repo. The developer engagement on this repo is great, though too. The challenge is that we don't want this to become a general Windows OS developer forum. Let's try it this way. The existing issues both focus on the inbox API. I've opened a separate feature request, cross-linked to these, that covers creating a new API, and spells out that it's distinct from updating the inbox functionality. We can track the inbox OS and Reunion asks separately, though we'd likely do one or the other. It's a subtle distinction, but worth separating for clarity.
Question for the thread - would you want a 1:1 replacement of WebAuthenticationBroker in Project Reunion that launched the browser for authentication then redirected back to the app? Or would you just want a Really Good Sample of how to register a protocol for your Win32 app and then use it from your authentication experience?
Jon Wiswall (@jonwis) Since it doesn't seem like WAB isn't getting fixed for non-UWP apps any time soon, is that Really Good Sample™️still on the table? I tried implementing this with protocol activation, but got stuck because it opened a new instance of my app instead of using the old one (yes, I tried activation redirection but there are barely any docs about it for UWP and none for WinAppSDK).
Thanks! Unfortunately it doesn't seem to work, opening a second instance causes both instances and Visual Studio to hang until I kill the app from Task Manager.
Joshua "Yoshi" Askharoun (@yoshiask), I can't reproduce your issue, so I am of not much help.
I had some issues with instances not closing when converting from Windows App SDK 0.8 to version 1.0. That issue disappeared by using Process.GetCurrentProcess().Kill(); to close the app.
In version 0.8, I used Application.Current.Exit(); to close the app. Maybe you can try this.
Wim Bokkers (@wbokkers) I switched to Application.Current.Exit() very early on because it actually caused the second instance to crash with a C++ exception, the message being something like "unexpected process exit".
I did manage to get single-instance working, it turns out the biggest issue is that setting breakpoints at anything involving SingleInstanceApplication seems to break it.
andreww-msft The spec is using C++ as an example with a main function. The samples are not about single-instancing. Am I correct? Can you point me to an example using WinUI 3 with C# to implement single instancing with redirection of all arguments to the single instance? I probably can make it work reading the spec, but I think it should be far less complicated to get a single instance app working in WinUI 3.
andreww-msft The spec is using C++ as an example with a main function. The samples are not about single-instancing. Am I correct? Can you point me to an example using WinUI 3 with C# to implement single instancing with redirection of all arguments to the single instance? I probably can make it work reading the spec, but I think it should be far less complicated to get a single instance app working in WinUI 3.
Activity
stevenbrix commentedon Jan 26, 2021
Adding some folks who may know if this API works in Win32 or not - MikeHillberg Jon Wiswall (@jonwis) Raymond Chen (@oldnewthing)
BenJKuhn commentedon Feb 8, 2021
Wim Bokkers (@wbokkers), thank you for bringing this to our attention. The best way you can help us is to file this in the feedback app. Once you've done that, please post the link here and I'll promote it to the right team for diagnosing & fixing. By filing in the feedback tool and collecting logs, you can help us better diagnose the issue.
Thanks,
Ben
riverar commentedon Feb 8, 2021
Ben Kuhn (@BenJKuhn) When you suggest folks file bugs in Feedback Hub, please provide the category and sub-category, as the likelihood we get it right (and the right on-demand diagnostics get executed) is very low.
BenJKuhn commentedon Feb 8, 2021
Rafael Rivera (@riverar), can you file that feedback in feedback hub (jk!).
In this case it's not going to matter much. I'm going to promote it in our database and directly assign it to the right team as soon as I get a link to the feedback. I understand that it's not always easy to map some features to feedback hub categories.
In this case, "Developer platform" -> "API feedback" would be appropriate.
Ben
riverar commentedon Feb 8, 2021
Ben Kuhn (@BenJKuhn) Fair.
If I remember correctly, that API still requires a CoreWindow.
Steps to reproduce
myButton_Clickhandler to be:Headscratcher corner
So taking a look at the "Developer platform" > "API Feedback" category/sub-category, I don't see any associated user-initiated feedback diagnostics. So that means there won't be any specific logs collected for this issue.
riverar commentedon Feb 8, 2021
Filed feedback on behalf of Wim Bokkers (@wbokkers) to take advantage of Ben Kuhn (@BenJKuhn)'s attention today
https://aka.ms/AAb2zbo
jonwis commentedon Feb 8, 2021
Chatting with the team that owns
WebAuthenticationBrokerthat's likely the concern. The "Broker" was necessary in a UWP so the user could enter their credentials into a Window displayed by the platform, rather than into one under the app's control. The Window was inferred from the thread callingRequestAsync(recall that a CoreWindow lives on a specific thread that it owns) so the broker knew where to show itself on screen and other attribution information.We're discussing options for how to support people who were building UWPs with CoreWindow but are now investigating Project Reunion WinUI3 apps on Desktop Bridge. This category of problem - APIs that implicitly or explicitly need a CoreWindow - is high on our list to address (hi AdamBr (@AdamBraden) !).
Question for the thread - would you want a 1:1 replacement of
WebAuthenticationBrokerin Project Reunion that launched the browser for authentication then redirected back to the app? Or would you just want a Really Good Sample of how to register a protocol for your Win32 app and then use it from your authentication experience?BenJKuhn commentedon Feb 8, 2021
For reference by OS team, the Windows work item number is 31649739. I left a back-pointer in the workitem to here as well.
Rafael Rivera (@riverar), for what it's worth, even the general diagnostics provide a number of ETW data providers that can be helpful in debugging API failures. It's not as nice as having a scenario-tailored log, but it's not an empty data set either.
riverar commentedon Feb 8, 2021
I would prefer for Microsoft to continue owning that experience. Writing all that OAuth2 goop correctly can be tough and presents quite a hurdle for developers wishing to just access some token-required services. Having a single implementation would also maintain the consistency
WebAuthenticationBrokersought to provide.Might be useful to bounce ideas off the active Microsoft Authentication Library folks as well. (psst Matthijs Hoekstra (@mahoekst))
1 remaining item
BenJKuhn commentedon Feb 11, 2021
This is also a duplicate of issue #366. This is a known gap in platform support that is being looked at and tracked as an OS bug. A potential outcome of that might be that we consider addressing it as a new API in reunion. There are pro's and con's to both approaches. The specific crash in the specific API wouldn't be fixed as a Project Reunion bug though.
riverar commentedon Feb 11, 2021
Ben Kuhn (@BenJKuhn) Given Reunion's goal of unifying access to existing Win32 and UWP APIs, it seems more appropriate to leave this (or the original) issue open, with a reference to the OS bug number, to track its progress.
Or perhaps this should be transferred to the Discussions area, as an Idea?
BenJKuhn commentedon Feb 11, 2021
We've been carrying a lot of issues over to the OS repo. The developer engagement on this repo is great, though too. The challenge is that we don't want this to become a general Windows OS developer forum. Let's try it this way. The existing issues both focus on the inbox API. I've opened a separate feature request, cross-linked to these, that covers creating a new API, and spells out that it's distinct from updating the inbox functionality. We can track the inbox OS and Reunion asks separately, though we'd likely do one or the other. It's a subtle distinction, but worth separating for clarity.
#441
riverar commentedon Feb 11, 2021
Ben Kuhn (@BenJKuhn) Sounds fair, thanks! 👍
yoshiask commentedon Feb 25, 2022
Jon Wiswall (@jonwis) Since it doesn't seem like WAB isn't getting fixed for non-UWP apps any time soon, is that Really Good Sample™️still on the table? I tried implementing this with protocol activation, but got stuck because it opened a new instance of my app instead of using the old one (yes, I tried activation redirection but there are barely any docs about it for UWP and none for WinAppSDK).
wbokkers commentedon Feb 25, 2022
Joshua "Yoshi" Askharoun (@yoshiask) To get single instancing to work with WinAppSDK, you can check out my solution here: https://gist.github.com/wbokkers/af326da5391bdb13b58529e720540178
yoshiask commentedon Feb 26, 2022
Thanks! Unfortunately it doesn't seem to work, opening a second instance causes both instances and Visual Studio to hang until I kill the app from Task Manager.
wbokkers commentedon Feb 28, 2022
Joshua "Yoshi" Askharoun (@yoshiask), I will look into it. I have it working this way in our production code, but maybe I'm missing something.
wbokkers commentedon Feb 28, 2022
Joshua "Yoshi" Askharoun (@yoshiask), I can't reproduce your issue, so I am of not much help.
I had some issues with instances not closing when converting from Windows App SDK 0.8 to version 1.0. That issue disappeared by using Process.GetCurrentProcess().Kill(); to close the app.
In version 0.8, I used Application.Current.Exit(); to close the app. Maybe you can try this.
yoshiask commentedon Feb 28, 2022
Wim Bokkers (@wbokkers) I switched to Application.Current.Exit() very early on because it actually caused the second instance to crash with a C++ exception, the message being something like "unexpected process exit".
I did manage to get single-instance working, it turns out the biggest issue is that setting breakpoints at anything involving SingleInstanceApplication seems to break it.
andreww-msft commentedon Mar 1, 2022
The WindowsApp SDK single-instancing approach is spec'd here , and there are samples here.
wbokkers commentedon Mar 1, 2022
andreww-msft The spec is using C++ as an example with a main function. The samples are not about single-instancing. Am I correct? Can you point me to an example using WinUI 3 with C# to implement single instancing with redirection of all arguments to the single instance? I probably can make it work reading the spec, but I think it should be far less complicated to get a single instance app working in WinUI 3.
andreww-msft commentedon Mar 15, 2022
Wim Bokkers (@wbokkers) The C# WinUI3 sample for instancing is here