MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
454 stars 55 forks source link

Hololens: Executing IWithMouseEvents.MouseEvent(...) releases MRTK's PointerDown. #3624

Open ydev0927 opened 1 year ago

ydev0927 commented 1 year ago

Description

Executing IWithMouseEvents.MouseEvent(...) releases MRTK's PointerDown.

Version SDK: com.microsoft.mixedreality.webview.unity-0.17.1-pre.3.tgz Runtime: Unity2021.3.24 (Run on Editor) Framework: Unity2021.3.24, MRTK2.8.3 OS: Windows10 22H2

Regression Was this working before but has regressed? > No. If yes, what version did this last work on?

Repro Steps

  1. Clone this repository. https://github.com/MicrosoftEdge/WebView2Samples/
  2. Open this sample in UnityEditor. https://github.com/MicrosoftEdge/WebView2Samples/tree/main/GettingStartedGuides/HoloLens2_GettingStarted/HoloLens2GetStartedApp
  3. Attach this script to "Canvas"
    
    using Microsoft.MixedReality.Toolkit.Input;
    using Microsoft.MixedReality.WebView;
    using UnityEngine;

public class Sample : MonoBehaviour, IMixedRealityPointerHandler { private IWebView webView;

private void Start()
{
    GetComponentInChildren<WebView>().GetWebViewWhenReady((IWebView webView) =>
    {
        this.webView = webView;
    });
}

public void OnPointerDown(MixedRealityPointerEventData eventData)
{
    Debug.Log("OnPointerDown");

    WebViewMouseEventData mouseEvent = new WebViewMouseEventData
    {
        X = 0,
        Y = 0,
        Type = WebViewMouseEventData.EventType.MouseDown,
        Button = WebViewMouseEventData.MouseButton.ButtonLeft,
        TertiaryAxisDeviceType = WebViewMouseEventData.TertiaryAxisDevice.PointingDevice
    };

    (webView as IWithMouseEvents).MouseEvent(mouseEvent);
}

public void OnPointerDragged(MixedRealityPointerEventData eventData)
{
    Debug.Log("Dragged");
}

public void OnPointerUp(MixedRealityPointerEventData eventData)
{
    Debug.Log("OnPointerUp");
}

public void OnPointerClicked(MixedRealityPointerEventData eventData)
{

}

}

4. Run it, put the pointer on the Canvas and press the left mouse button.
5. The following is logged to the console:

OnPointerDown Dragged OnPointerUp

I expect only PointerDown (and Dragged) to be logged.
Commenting out this line gives the expected behavior.

(webView as IWithMouseEvents).MouseEvent(mouseEvent);



<!-- Call out the Expected behavior, and the Actual behavior -->

<!-- Extra / Helpful -->
**Screenshots**
![image](https://github.com/MicrosoftEdge/WebView2Feedback/assets/44051153/c79896a8-e098-4747-af57-4227eac160b5)

**Additional context**

[AB#45473968](https://microsoft.visualstudio.com/90b2a23c-cab8-4e7c-90e7-a977f32c1f5d/_workitems/edit/45473968)
novac42 commented 1 year ago

Thanks for reporting the issue and sorry you are running into this. I've assigned this to a dev who can help follow up.

champnic commented 1 year ago

I've added this as a bug on our backlog and am forwarding it to our Hololens team. Thanks!

michaelfarnsworth commented 1 year ago

@ydev0927 In my testing, this appears to be isolated to the Unity editor. I'm not seeing these spurious pointer-up events when deploying and running on the device. Have you observed this as well?

ydev0927 commented 1 year ago

@michaelfarnsworth Today, I checked on my device. There was no problem. This issue seems to be UnityEditor specific.

Remarks I used Unity2020.3.33f1 for checking on device as I also crash with this issue. https://github.com/MicrosoftEdge/WebView2Samples/issues/198

michaelfarnsworth commented 1 year ago

@ydev0927 thanks for the update. We'll follow up with the Unity team about this issue. Though, it's only in-editor, it could add some frustration to developing and debugging input issues.