Skip to content
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

Crash when using SetVirtualHostMapping #3652

Open
ydev0927 opened this issue Jul 20, 2023 · 10 comments
Open

Crash when using SetVirtualHostMapping #3652

ydev0927 opened this issue Jul 20, 2023 · 10 comments
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@ydev0927
Copy link

ydev0927 commented Jul 20, 2023

Description

Crash when using SetVirtualHostMapping

Version
SDK: com.microsoft.mixedreality.webview.unity-0.17.1-pre.3.tgz
Runtime: Unity2020.3.33
Framework: Unity2020.3.33, MRTK2.8.3
OS: (Unity Editor) Windows 10 22H2, (Hololens2) 22621.1120.arm64fre.ni_release_svc_sydney_rel_prod.230707-1012

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. Resolve compilation errors
    • Do "Restore Features" in Mixed Reality Feature Tool.
    • remove this line from package.json
      "com.unity.collab-proxy": "2.0.3",
      
  3. Open this sample in UnityEditor.
    https://github.com/MicrosoftEdge/WebView2Samples/tree/main/GettingStartedGuides/HoloLens2_GettingStarted/HoloLens2GetStartedApp
  4. Attach this script to "WebView"
using Microsoft.MixedReality.WebView;
using System;
using UnityEngine;

public class WebViewExample : MonoBehaviour
{
    private void Start()
    {
        var webViewComponent = gameObject.GetComponent<WebView>();

        webViewComponent.GetWebViewWhenReady((IWebView webView) =>
        {
            ((IWithVirtualHost)webView).SetVirtualHostMapping("webview2.sample", "Assets\\Html");

            // Navigate to our local content.
            // webViewComponent.Load(new Uri("http://webview2.sample/demo.html")); // comment out!!
        });
    }
}

source: https://learn.microsoft.com/en-us/microsoft-edge/webview2/get-started/hololens2#setvirtualhostnametofoldermapping-and-setvirtualhostmapping

  1. And create a "{ProjectFolder}/Assets/Html/demo.html". (I don't think it matters)

  2. When I run it, it crashes. (Both Editor and Hololens.)

Screenshots

Additional context

AB#45688087

@ydev0927 ydev0927 added the bug Something isn't working label Jul 20, 2023
@LiangTheDev
Copy link
Member

@ydev0927 could you share more details about the crash? Like the exception info, stack of the crash, or the dump file?

@ydev0927
Copy link
Author

@LiangTheDev There is no log by "Application.logMessageReceivedThreaded". I have crashdmp from Hololens2 DevicePortal, but filesize is 576MB. What should i do?

@LiangTheDev
Copy link
Member

Could you zip the dump file, upload it to some network/cloud drive and share the link with me at lzhao@microsoft.com?

@ydev0927
Copy link
Author

@LiangTheDev Okay. I shared a file with you via GoogleDrive.
WebView2HoloLensSample.exe.6528.dmp

@LiangTheDev
Copy link
Member

The error was 0x80070003 (The system cannot find the path specified.), which indicate that there is no "Assets\Html" sub folder in the directory where the app exe file is in. If you run the app under debugger, there should be some debug message indicating this. It is likely that the app package doesn't carry the assets\html files as expected. Try to verify that the VS project builds the package with those files.

@ydev0927
Copy link
Author

@LiangTheDev Thanks for the analysis.
It worked fine when I placed the "Html" directory under the StreamingAssets directory and referenced it with an absolute path.
It would be nice to be fixed to throw an exception if the directory doesn't exist.

  • move directory

{ProjectFolder}/Assets/Html

{ProjectFolder}/Assets/StreamingAssets/Html

  • change source code
        webViewComponent.GetWebViewWhenReady((IWebView webView) =>
        {
            ((IWithVirtualHost)webView).SetVirtualHostMapping("webview2.sample", System.IO.Path.Combine(Application.streamingAssetsPath, "Html"));

            // Navigate to our local content.
            webViewComponent.Load(new Uri("http://webview2.sample/demo.html"));
        });

@LiangTheDev
Copy link
Member

If you put a try-catch around the call to SetVirtualHostMapping, would it catch the error as an exception or still crash the application?

@ydev0927
Copy link
Author

crash.

@champnic champnic added the tracked We are tracking this work internally. label Jul 25, 2023
@champnic
Copy link
Member

@michaelfarnsworth Would you be able to help here? Sounds like when the SetVirtualHostMapping is called with an invalid path it causes an exception and crash that is not exposed or try-catch-able by the app.

@michaelfarnsworth
Copy link
Collaborator

@champnic I'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

4 participants