WebView2Feedback icon indicating copy to clipboard operation
WebView2Feedback copied to clipboard

[Bug]: WPF hybrid - touch in WebView2 makes mouse invisible even when moving over WPF

Open wgala-tomra opened this issue 1 year ago • 5 comments

What happened?

Hello!

We have hybrid application that has WPF and Blazor (presented by WebView2 WPF control) in it. We are in transition from WPF to Blazor which takes time, so we change it part by part. Because of WebView2's airspace issue we cannot fully convert our views to Blazor, we need to do it step by step doing small parts like notifications, that appear always on top first. So most of the WebView2 areas are quite small and may be closed on tap/click.

App: We provide touchscreen app with mouse support when it is connected. App is running on machine with touch panel, which sometimes needs to be accessed via remote desktop and by people not having touchscreen, so they need mouse/keyboard support. Also, there are cases when there users being near machine and connecting to the machine are giving access to the machine to each other.

Bug: When tapping (touching) on WebView2 part of application it makes mouse cursor invisible (this is expected). The problem is that mouse doesn't go visible on mouse moving on WPF part. When moving out of the application window mouse appears, when entering application which is still in WPF it disappears again. Once mouse movement is on WebView2/Blazor part it appears again, both for WebView2 part and WPF. Since we have small things that may disappear once it's clicked/tapped done in Blazor it may be very hard to restore mouse by the user (which is not aware of such issue and which parts are in Blazor).

Remarks: While investigating issue I have noticed that WebView2 is setting cursor flag to hidden (0x00) instead of CURSOR_SUPPRESSED which should be the case for touch actions (https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-cursorinfo). I believe this is the main cause here.

Also, I have noticed that WebView2 control doesn't mouse move to the location where touch occurred.

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

124.0.2478.67

SDK Version

1.0.2478.35

Framework

WPF

Operating System

Windows 10

OS Version

10.0.19045

Repro steps

I have created simple WPF window that is helpful to reproduce issue. Left half of the window is WebView2 WPF control and right part is WPF (red background)

<Window x:Class="BlazorWPF.SampleBlazor"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        xmlns:wpf="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf" 
        Title="SampleBlazor" Height="400" Width="800"
        Background="Red">
    <Grid>
        <wpf:WebView2 Width="400" 
                      Height="400" 
                      HorizontalAlignment="Left"
                      VerticalAlignment="Top"
                      Source="https://bing.com">

        </wpf:WebView2>
        <Button Width="120" Height="40"
                HorizontalAlignment="Right"
                VerticalAlignment="Top">Click me</Button>
    </Grid>
</Window>

Steps:

  • move mouse on red area (WPF area)
  • tap/touch on Bing search (WebView2) part of the screen (cursor disappears - as expected)
  • move mouse over red area, without hovering over Bing part (cursor is hidden - not expected)
  • move mouse out of application (cursor is now visible)
  • move mouse to red area, without hovering over Bing part (cursor is hidden- not expected)
  • move mouse to Bing part (notice that mouse cursor is visible again)
  • move mouse to red part (cursor is visible)

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

Don't know

Last working version (if regression)

No response

AB#50630885

wgala-tomra avatar May 01 '24 13:05 wgala-tomra

Was able to repro this issue, it will be tracked in out backlog

tochukwuIbeEkeocha avatar May 06 '24 21:05 tochukwuIbeEkeocha

Hey @wgala-tomra - we've had trouble reproducing this issue recently. Do you know if you are only seeing this on Windows 10, or Windows 10 and Windows 11?

champnic avatar Sep 03 '24 22:09 champnic

Hey @champnic, it is still reproducible both on Win10 and Win11. I built the app with WebView2 SDK 1.0.2739.15 with .NET 8.0, on 19045.4780 Windows 10 machine. It was tested on:

  • same machine (Win10) with WebView2 Runtime 128.0.2739.54
  • Win11 with 22631.4037 built and WebView2 Runtime 128.0.2739.54

Just a reminder, for it to reproduce mouse cannot be over WebView2 area, it has to be outside of it and it cannot be mouse click, it has to be touch, that is done on WebView2 area. After that if mouse doesn't hover over WebView2 area then it will be invisible/hidden on App's WPF area (red zone).

wgala-tomra avatar Sep 04 '24 08:09 wgala-tomra

Thanks @wgala-tomra - I was able to get it to repro. I realized I had a feature enabled which was inadvertently fixing the issue. In your app, can you please try:

Environment.SetVariable("COREWEBVIEW2_FORCED_HOSTING_MODE", "COREWEBVIEW2_HOSTING_MODE_WINDOW_TO_VISUAL");

champnic avatar Sep 04 '24 23:09 champnic

@champnic it seems to fix the issue, cursor reappears at WPF part after touch at WebView2 part, so main issue seems to be fixed :) Thanks! Other one, with mouse not moving to the touch area, is still not working but it is minor issue (at least to me). Thanks again!

wgala-tomra avatar Sep 05 '24 06:09 wgala-tomra