Search code examples
webrtcmicrosoft-edgemdns

How to change Microsoft Edge WebView2 mDNS behavior by calling CreateWebView2EnvironmentWithDetails?


I'm developing WebRTC application using Microsoft Edge WebView2. I want to change the value of edge://flags/#enable-webrtc-hide-local-ips-with-mdns flag from 'Default' to 'Disabled'.

According to the MSDN doc https://learn.microsoft.com/en-us/microsoft-edge/hosting/webview2/reference/webview2.idl, the API CreateWebView2EnvironmentWithDetails has an argument additionalBrowserArguments which can change chromium flags. I've tried the following values which don't work at all.

WCHAR args[] = TEXT("--enable-webrtc-hide-local-ips-with-mdns=0");
WCHAR args[] = TEXT("--disable-webrtc-hide-local-ips-with-mdns");
WCHAR args[] = TEXT("--edge-webview-switches=\"--enable-webrtc-hide-local-ips-with-mdns=0\"");
WCHAR args[] = TEXT("--edge-webview-switches=--enable-webrtc-hide-local-ips-with-mdns=0");
WCHAR args[] = TEXT("--edge-webview-switches=--disable-webrtc-hide-local-ips-with-mdns");

The above args won't work in the API

CreateWebView2EnvironmentWithDetails(nullptr, nullptr, args, callback_handler);

I'm using Microsoft Edge with version 80.0.315.0 (Official build) canary (64-bit) on a Window 10.

Thanks in advance


Solution

  • According to the MSDN doc https://learn.microsoft.com/en-us/microsoft-edge/hosting/webview2/reference/webview2.idl, the API CreateWebView2EnvironmentWithDetails has an argument additionalBrowserArguments which can change chromium flags. I've tried the following values which don't work at all.

    I've tried it with official Samples and Process Explorer. The Arguments was correctly added to the process:

    enter image description here

    The reason why it doesn't work is because there is no such switch:

    Here is the switch list found at Run Chromium with flags. I searched through the list and didn't find a switch named --enable-webrtc-hide-local-ips-with-mdns.

    When I enabled the flag manually through edge://flags/#enable-webrtc-hide-local-ips-with-mdns and checked it, the switch looks like this:

    enter image description here

    So the answer is clear, you should change the parameter from --enable-webrtc-hide-local-ips-with-mdns to --enable-features=WebRtcHideLocalIpsWithMdns