Skip to content

Commit 07e9c39

Browse files
committed
Merge branch 'main' into victorhuangwq/updatetemplate
2 parents 312d1be + dbf21fb commit 07e9c39

File tree

7 files changed

+324
-5
lines changed

7 files changed

+324
-5
lines changed

.github/workflows/createAdo.yml renamed to .github/workflows/syncAdo.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ jobs:
1919
ado_project: 'Edge'
2020
ado_area_path: 'Edge\Web Experience\WebView2'
2121
ado_tags: 'WV2_GitHub'
22+
ado_gh_closed_tag: 'WV2_GitHub_Closed'

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
1-
# WebView2 Feedback
1+
# Microsoft Edge WebView2
22

3-
A place for developers to report feedback or search existing issues for [Microsoft Edge WebView2 control](https://aka.ms/webview). Open an [issue](https://github.com/MicrosoftEdge/WebViewFeedback/issues/new) to submit a feature request or bug report. Any "feature request" or "bug" that has the "tracked" label added means that we are also tracking the issue on our internal backlog.
3+
Welcome to Microsoft Edge WebView2 feedback repository.
44

5-
To get the latest news, API proposals, and SDK Release announcements, please subscribe to the [WebView2Announcements](https://github.com/MicrosoftEdge/WebView2Announcements) repo!
5+
This is a place for all developers of the [Microsoft Edge WebView2](https://aka.ms/webview) to report bugs, make feature requests, and ask questions and have discussions about WebView2.
66

7-
Tips or Best Practices from other WebView2 devs use the ["Tips" label](https://github.com/MicrosoftEdge/WebView2Feedback/labels/Tip%21).
7+
- 🐞 [How to report a bug](#🐞-how-to-report-a-bug)
8+
- 💡 [How to request a feature](#💡-how-to-request-a-feature)
9+
-[Ask a question about WebView2](https://github.com/MicrosoftEdge/WebView2Feedback/discussions/new?category=q-a)
10+
- 💬 [Discuss WebView2 with other developers](https://github.com/MicrosoftEdge/WebView2Feedback/discussions)
11+
- 📣 [Subscribe to WebView2Announcements for news, API proposals and SDK Release announcements](https://github.com/MicrosoftEdge/WebView2Announcements)
12+
- 📖 [Read the WebView2 documentation](https://aka.ms/webview)
813

14+
15+
### 🐞 How to report a bug
16+
17+
1. [Search for existing open bugs](https://github.com/MicrosoftEdge/WebView2Feedback/issues?q=is%3Aissue+is%3Aopen+label%3Abug) to avoid duplicates.
18+
1. If you find that your bug is already reported, give it a 👍 reaction, and add a comment with additional details that may help us investigate.
19+
1. If the issue is not already reported, [open a new issue](https://github.com/MicrosoftEdge/WebView2Feedback/issues/new/choose).
20+
1. Tracked issues will be labeled with the `tracked` label. If you see this label, we are aware of the issue and tracking it on our internal backlog.
21+
22+
### 💡 How to request a feature
23+
24+
1. [Search for existing feature request](https://github.com/MicrosoftEdge/WebView2Feedback/issues?q=is%3Aissue+is%3Aopen+label%3A%22feature+request%22) to avoid duplicates.
25+
1. If you find a similar feature request, give it a 👍 reaction, and provide additional context into how you would use the feature.
26+
2. If the feature is not already requested, [open a new issue](https://github.com/MicrosoftEdge/WebView2Feedback/issues/new/choose).
27+
1. Tracked issues will be labeled with the `tracked` label. If you see this label, we are aware of the issue and tracking it on our internal backlog.
28+
29+
## Code of Conduct
930
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

diagnostics/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ This folder contains directions for gathering various detailed diagnostics/logs
55
- [ETW Trace](etw.md): Event Tracing for Windows (ETW) traces include detailed events on system state and the activities WV2 was doing before and when an issue occurs.
66
- [Installer Logs](install.md): Installer logs include information about any errors that WV2's installer/updater hit when trying to install or update the WV2 runtime.
77
- [GPU Info](gpu.md): GPU logs include details on the user's GPU and any potential graphics or rendering issues.
8-
- [Network Logs](network.md): Network logs include the network requests, responses, and details on any errors when loading files.
8+
- [Network Logs](network.md): Network logs include the network requests, responses, and details on any errors when loading files.
9+
- [Code Integrity](code_integrity.md): how to root cause STATUS_INVALID_IMAGE_HASH errors.

diagnostics/code_integrity.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Code Integrity in WebView2
2+
3+
## Why it is important
4+
Code integrity is a feature of Windows that verifies the authenticity and integrity of the code that runs on your system. It helps protect your system from malware, tampering, and unauthorized changes. Code integrity checks the digital signatures of the files that are loaded into memory, and prevents any file that does not have a valid signature from running in webview2.
5+
6+
## Symptoms
7+
Child process failed with kind COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_EXITED
8+
and exit code -1073740760 or STATUS_INVALID_IMAGE_HASH.
9+
10+
Users may see error page in the WebView2:
11+
12+
![Compatibility problem](compatibility_problem.png)
13+
14+
## Identify the dll
15+
16+
**Compatibility problem** web page may show the culprit file otherwise use Event Viewer.
17+
18+
Open Event Viewer by typing eventvwr in the search box on the taskbar and selecting the app.
19+
20+
- In the left pane, expand Windows Logs and click on System.
21+
- In the right pane, click on Filter Current Log.
22+
- In the Filter tab, under Event sources, select Microsoft-Windows-CodeIntegrity and click on OK.
23+
- You will see a list of events related to code integrity – search for the ones with msedgewebview2.exe process.
24+
- The file name and path of the file that caused the code integrity violation are shown in the message.
25+
26+
27+
28+

diagnostics/compatibility_problem.png

41.2 KB
Loading

specs/AllowHostInputProcessing.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Background
2+
WebView2 .NET developers often encounter issues where certain default events are not raised in the WebView2 .NET control.
3+
4+
This issue occurs because user inputs are directly delivered to the browser, and the host application does not receive the corresponding messages.
5+
6+
This causes some default event handling API of .NET control not to work, such as PreProcessMessage and ProcessCmdKey in WinForms.
7+
8+
It also prevents some keys from reaching Key Event realated APIs such as OnKeyDown and ToolStripMenuItem.
9+
10+
In order to solve this type of issue, we provide an api which allows user inputs pass through the browser to the host app.
11+
12+
# Description
13+
`AllowHostInputProcessing` allows user input messages(keyboard, mouse, touch, and pen) to pass through the browser window to be received by an app process window.
14+
15+
The messages can be received by Win32 API ::GetMessage() or ::PeekMessage(). This provides the host app a chance to handle the message before dispatching to the WebView2 HWND.
16+
17+
If the host app does not handle input, it is forwarded to the browser process on the user's behalf. This API does not introduce any requirement for the developer to forward all input as is the case with visual hosting. This API should not be used with visual hosting, and has no effect when using CreateCoreWebView2CompositionControllerWithOptions to create the controller.
18+
19+
Setting `AllowHostInputProcessing` to `TRUE` makes `AcceleratorKeyPressed`(all platforms) and `OnKeyDown`(WinForms only) event asynchronous.
20+
21+
# Examples
22+
## Win32 C++
23+
```cpp
24+
// We assume WebView2 is hosted in a MFC application. CMFCApplicationApp is a CWinApp.
25+
// This function can not be triggered by default when focus is in WebView.
26+
// It can be triggered by setting 'AllowHostInputProcessing' to true.
27+
BOOL CMFCApplicationApp::PreTranslateMessage(MSG* pMsg) {
28+
if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP ||
29+
pMsg->message == WM_SYSKEYDOWN || pMsg->message == WM_SYSKEYUP && webview_has_focus_)
30+
// Prehandle the message. The message will not be sent to WebView if return TRUE.
31+
return HandleMsgBeforeWebView(pMsg);
32+
return FALSE;
33+
}
34+
35+
// Create a ControllerOptions and set 'AllowHostInputProcessing' to TRUE.
36+
HRESULT CreateControllerWithInputPassthrough()
37+
{
38+
auto webViewEnvironment10 = m_webViewEnvironment.try_query<ICoreWebView2Environment10>();
39+
if (!webViewEnvironment10)
40+
{
41+
FeatureNotAvailable();
42+
return S_OK;
43+
}
44+
45+
wil::com_ptr<ICoreWebView2ControllerOptions> options;
46+
CHECK_FAILURE(webViewEnvironment4->CreateCoreWebView2ControllerOptions(options.GetAddressOf()));
47+
48+
wil::com_ptr<ICoreWebView2ControllerOptions3> webView2ControllerOptions3;
49+
if (SUCCEEDED(options->QueryInterface(IID_PPV_ARGS(&webView2ControllerOptions3))))
50+
{
51+
CHECK_FAILURE(webView2ControllerOptions3->put_AllowHostInputProcessing(TRUE));
52+
}
53+
54+
CHECK_FAILURE(webViewEnvironment10->CreateCoreWebView2ControllerWithOptions(
55+
m_mainWindow, options.get(),
56+
Callback<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>(
57+
this, &AppWindow::OnCreateCoreWebView2ControllerCompleted)
58+
.Get()));
59+
60+
return S_OK;
61+
}
62+
```
63+
64+
### .NET, WinRT
65+
```c#
66+
67+
partial class BrowserForm
68+
{
69+
// This function can not be triggered by default when focus is in WebView.
70+
// It can be triggered by setting 'AllowHostInputProcessing' to true.
71+
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
72+
{
73+
//DoSomething();
74+
return base.ProcessCmdKey(ref msg, keyData);
75+
}
76+
77+
// ...
78+
private Microsoft.Web.WebView2.WinForms.WebView2 webView2Control;
79+
}
80+
81+
CoreWebView2Environment _webViewEnvironment;
82+
public CreateWebView2Controller(IntPtr parentWindow)
83+
{
84+
CoreWebView2ControllerOptions controllerOptions = _webViewEnvironment.CreateCoreWebView2ControllerOptions();
85+
controllerOptions.AllowHostInputProcessing = true;
86+
87+
CoreWebView2Controller controller = null;
88+
89+
controller = await _webViewEnvironment.CreateCoreWebView2ControllerAsync(parentWindow, controllerOptions);
90+
91+
//...
92+
}
93+
```
94+
95+
# API Details
96+
## Win32 C++
97+
```IDL
98+
interface ICoreWebView2ControllerOptions3;
99+
100+
interface ICoreWebView2ControllerOptions3 : IUnknown {
101+
/// `AllowHostInputProcessing` property is to enable/disable input passing through
102+
/// the app before being delivered to the WebView2. This property is only applicable
103+
/// to controllers created with `CoreWebView2Environment.CreateCoreWebView2ControllerAsync` and not
104+
/// composition controllers created with `CoreWebView2Environment.CreateCoreWebView2CompositionControllerAsync`.
105+
/// By default the value is `FALSE`.
106+
[propget] HRESULT AllowHostInputProcessing([out, retval] BOOL* value);
107+
/// Sets the `AllowHostInputProcessing` property.
108+
/// Setting this property has no effect when using visual hosting.
109+
[propput] HRESULT AllowHostInputProcessing([in] BOOL value);
110+
}
111+
```
112+
113+
## .NET, WinRT
114+
```c#
115+
namespace Microsoft.Web.WebView2.Core
116+
{
117+
runtimeclass CoreWebView2ControllerOptions;
118+
runtimeclass CoreWebView2Environment;
119+
runtimeclass CoreWebView2;
120+
runtimeclass CoreWebView2Profile;
121+
122+
runtimeclass CoreWebView2ControllerOptions
123+
{
124+
// ...
125+
126+
Boolean AllowHostInputProcessing { get; set; };
127+
}
128+
}
129+
```

specs/NewWindowSourceFrameInfo.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
Source Frame Info for New Window Requested
2+
===
3+
4+
# Background
5+
Currently there is no way to determine the source frame of a new window request. This information
6+
can be useful when deciding how to open the content. For example, you may want to open requests
7+
that originate in a 3rd party frame in the default browser instead of in a new WebView. The
8+
WebView2 team is extending `NewWindowRequestedEventArgs` with an `OriginalSourceFrameInfo` property
9+
to make this easier. Here we described the updated API.
10+
11+
# Examples
12+
## OriginalSourceFrameInfo on NewWindowRequestedEventArgs
13+
```c#
14+
// Register a handler for the NewWindowRequested event.
15+
// This handler will check the source frame info to determine how to open the
16+
// request. Depending on the source frame URI, it will provide a new app window
17+
// or open using the default browser.
18+
webView.CoreWebView2.NewWindowRequested += delegate (
19+
object webView, CoreWebView2NewWindowRequestedEventArgs args)
20+
{
21+
// The host can decide how to open based on source frame info,
22+
// such as URI. For example, if the source is a 3rd party frame, open using
23+
// the default browser.
24+
bool useDefaultBrowser = IsThirdPartySource(
25+
args.OriginalSourceFrameInfo.Source);
26+
if (useDefaultBrowser)
27+
{
28+
ProcessStartInfo startInfo = new ProcessStartInfo
29+
{
30+
FileName = args.OriginalSourceFrameInfo.Source,
31+
// Open the URI in the default browser.
32+
UseShellExecute = true
33+
};
34+
Process.Start(startInfo);
35+
args.Handled = true;
36+
}
37+
else
38+
{
39+
CoreWebView2Deferral deferral = args.GetDeferral();
40+
MainWindow main_window = new MainWindow(
41+
webView.CreationProperties, args.Uri);
42+
main_window.OnWebViewFirstInitialized = () =>
43+
{
44+
using (deferral)
45+
{
46+
args.Handled = true;
47+
args.NewWindow = main_window.webView.CoreWebView2;
48+
}
49+
};
50+
main_window.Show();
51+
}
52+
};
53+
```
54+
```cpp
55+
// Register a handler for the NewWindowRequested event.
56+
// This handler will check the source frame info to determine how to open the
57+
// request. Depending on the source frame URI, it will provide a new app window
58+
// or open using the default browser.
59+
CHECK_FAILURE(m_webView->add_NewWindowRequested(
60+
Callback<ICoreWebView2NewWindowRequestedEventHandler>(
61+
[this](ICoreWebView2* sender, ICoreWebView2NewWindowRequestedEventArgs* args)
62+
{
63+
bool useDefaultBrowser = false;
64+
Microsoft::WRL::ComPtr<ICoreWebView2NewWindowRequestedEventArgs3> args3;
65+
if (SUCCEEDED(args->QueryInterface(IID_PPV_ARGS(&args3))))
66+
{
67+
Microsoft::WRL::ComPtr<ICoreWebView2FrameInfo> frame_info;
68+
if (SUCCEEDED(args3->get_OriginalSourceFrameInfo(&frame_info))
69+
&& frame_info)
70+
{
71+
// The host can decide how to open based on source frame info,
72+
// such as URI. For example, if the source is a 3rd party frame,
73+
// open using the default browser.
74+
wil::unique_cotaskmem_string source;
75+
CHECK_FAILURE(frame_info->get_Source(&source));
76+
useDefaultBrowser = IsThirdPartySource(source.get());
77+
}
78+
}
79+
if (useDefaultBrowser)
80+
{
81+
// Open the URI in the default browser.
82+
ShellExecute(
83+
nullptr, L"open", source.get(), nullptr, nullptr, SW_SHOWNORMAL);
84+
CHECK_FAILURE(args->put_Handled(TRUE));
85+
}
86+
else
87+
{
88+
Microsoft::WRL::ComPtr<ICoreWebView2Deferral> deferral;
89+
CHECK_FAILURE(args->GetDeferral(&deferral));
90+
AppWindow* newAppWindow = new AppWindow(
91+
m_creationModeId, GetWebViewOption(), L"none", m_userDataFolder,
92+
false, nullptr, true, windowRect, !!shouldHaveToolbar);
93+
newAppWindow->m_onWebViewFirstInitialized =
94+
[args, deferral, newAppWindow]()
95+
{
96+
CHECK_FAILURE(args->put_NewWindow(newAppWindow->m_webView.get()));
97+
CHECK_FAILURE(args->put_Handled(TRUE));
98+
CHECK_FAILURE(deferral->Complete());
99+
};
100+
}
101+
return S_OK;
102+
})
103+
.Get(),
104+
nullptr));
105+
```
106+
107+
# API Details
108+
109+
```
110+
/// This is a continuation of the `ICoreWebView2NewWindowRequestedEventArgs` interface.
111+
[uuid(92f08d94-70bd-4d2b-8332-18bd7d3b2b7c), object, pointer_default(unique)]
112+
interface ICoreWebView2NewWindowRequestedEventArgs3 :
113+
ICoreWebView2NewWindowRequestedEventArgs2 {
114+
/// The frame info of the frame where the new window request originated. The
115+
/// `OriginalSourceFrameInfo` is a snapshot of frame information at the time when the
116+
/// new window was requested. See `ICoreWebView2FrameInfo` for details on frame
117+
/// properties.
118+
[propget] HRESULT OriginalSourceFrameInfo([out, retval] ICoreWebView2FrameInfo** frameInfo);
119+
}
120+
```
121+
122+
```c#
123+
namespace Microsoft.Web.WebView2.Core
124+
{
125+
runtimeclass CoreWebView2NewWindowRequestedEventArgs
126+
{
127+
// ...
128+
129+
[interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2NewWindowRequestedEventArgs3")]
130+
{
131+
// The frame info of the frame where the new window request originated. The
132+
// `OriginalSourceFrameInfo` is a snapshot of frame information at the time when the
133+
// new window was requested. See `CoreWebView2FrameInfo` for details on frame
134+
// properties.
135+
CoreWebView2FrameInfo OriginalSourceFrameInfo { get; };
136+
}
137+
}
138+
}
139+
```

0 commit comments

Comments
 (0)