4

Every request from Edge browser needs a corresponding response to be sent. If not, the companion UWP(and the associated Win32 App, if any) exit citing "SystemPolicy" as the reason. To illustrate the problem, I can refer to the SecureInput sample.

    /// <summary>
    /// Receives message from Extension (via Edge)
    /// </summary>
    private async void OnAppServiceRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
    {
        AppServiceDeferral messageDeferral = args.GetDeferral();

        try
        {
            if (this.desktopBridgeAppLaunched)
            {
                this.currentConnectionIndex = Int32.Parse(sender.AppServiceName);
                this.desktopBridgeConnection = desktopBridgeConnections[this.currentConnectionIndex];

                // Send message to the desktopBridge component and wait for response
                AppServiceResponse desktopBridgeResponse = await this.desktopBridgeConnection.SendMessageAsync(args.Request.Message);
                await args.Request.SendResponseAsync(desktopBridgeResponse.Message);
            }
            else
            {
                throw new Exception("Failed to launch desktopBridge App!");
            }
        }
        finally
        {
            messageDeferral.Complete();
        }
    }

By commenting out the line that calls "SendResponseAsync(...)", the UWP and the Win32 App(PasswordInputProtection.exe) are exiting because of the "OnAppServicesCanceled(...)" handler being invoked with SystemPolicy reason.

I understand that for this particular example, it's meaningless not to send a response back. But I have scenarios where there's no need send a response back to the Edge Extension. Instead, I intend to use SendMessageAsync(...) from the Win32 App to communicate with the Extension through the UWP App.

Also, I noticed that the native messaging samples I found online send at-least a useless ACK message back to the Extension from the UWP. So, Is it by design that a response needs to be sent or am I missing something here?

Stefan Wick MSFT
  • 13,600
  • 1
  • 32
  • 51
raghurk
  • 41
  • 3
  • My expectation would be that an empty response is auto-generated at the time you call messageDeferral.Complete() without having called SendResponseAsync(). I have just tried it out here and that's how it seems to be working on my machine. My test was a pure AppService scenario (not Edge Extension), and on the latest Insider build (I assume you are on 16299), so those may be possible differences between our two tests. Let me follow up with the Edge Extension folks to see what could be missing here. – Stefan Wick MSFT Dec 05 '17 at 14:32
  • Thanks for your response Stefan. 1. Yes, I'm on 16299. 2. So u mean to say that u tried one way async communication between two UWP apps (neither being EdgeExtension) and they work fine ?? I haven't tried this out. However, I tried to send empty response in SendResponseAsync() and shockingly the EdgeBrowser itself crashes consistently. Looking forward for your reply on Edge Extension + UWP – raghurk Dec 05 '17 at 14:56

1 Answers1

1

The Edge team has investigated this and confirmed it's a bug in one of their components. They are working on a fix for the next update. Until the fix is out, you will need to always send a response.

Thanks for reporting the problem, and sorry for the inconvenience this may cause!

Stefan Wick MSFT
  • 13,600
  • 1
  • 32
  • 51