-
Notifications
You must be signed in to change notification settings - Fork 52
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebView window position is not set correctly #3659
Comments
Thanks for reporting the issue and sorry you are running into it. I've assigned this to a dev who can help follow up on this. |
@ztextplus What are the steps to reproduce the issue? Does this involve multiple monitors or changing DPI scaling? So just the Intermediate D3D Window position is wrong, but the Chrome_WidgetWin_1 window is correctly positioned? The positioning of the Intermediate D3D Window is code that is shared with Chromium. Is your app sizing/positioning the WebView2 using the CoreWebView2Controller::put_Bounds API or by directly interacting with the HWNDs? |
@bradp0721 The answer to your question is as follows: |
@ztextplus you said this happens occasionally. I haven't seen any other reports of this type of issue, so I'm trying to figure out how to get a repro or get an idea of what could be going wrong. When do you notice this happening? Does the app launch this way? Does this happen after closing and opening the laptop lid? Does it happen after moving/resizing the application? |
@bradp0721 After careful analysis, we found a problem, This leads to a problem. Before receiving the callback of OnNavigationCompleted, we never call CoreWebView2Controller::put_Bounds to set the position of WebView2. We will not call CoreWebView2Controller::put_Bounds to set the position of WebView2 until we receive the callback of OnNavigationCompleted. . I don't know if doing this will cause potential problems with WebView2, but we have been doing this before, and occasionally this exception occurs. |
Are you showing the WebView2 before receiving OnNavigationCompleted? You need to call put_Bounds before making the WebView2 visible to the user. Otherwise, you're at the mercy of however Windows default positioned the HWNDs during creation. I'm actually a little surprised that any WebView2 content is visible without calling put_Bounds. Also, changing the size of the WebView2 causes the HTML page to re-layout its content. So currently, you are waiting for the page to completely load, then calling put_Bounds to size it, which causes a relayout. If you know what size the WebView2 will be, you should call put_Bounds before calling Navigate. That way the WebView2 loads and renders its content at the desired size. Then you can show the WebView2 when you receive OnNavigationCompleted. |
Description
First of all, this problem occurs occasionally. During the test,.it was found that the WebView window was shifted to the upper left.
As shown in the figure below, the webview is shifted to the left, causing the non-webview content on the right to be displayed:
Using the window tool, we found that the position of the window below is not set correctly, but the position of the parent window is set correctly
Version
SDK: .0.1264.42 release
Runtime: 114.0.1823.82
Framework: Win32
OS: Win10
The text was updated successfully, but these errors were encountered: