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

When opening a FileExplorer Dialog over a WebView2 instance the app freeze and then crash #4648

Closed
RobertGlobant20 opened this issue Jun 25, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@RobertGlobant20
Copy link

RobertGlobant20 commented Jun 25, 2024

What happened?

I've created a simple WebView2 app displaying a very simple React component, the component has a button that when is clicked send a message to .NET to open a FileOpen Dialog, after some seconds of the Dialog being opened the application freeze (both the .NET app and the File Explorer Dialog), then the app suddently closes.

In the EventViewer->Windows Logs->Application I've found an Error Entry that says:

Faulting application name: WebView2OpenDialogTester.exe, version: 1.0.0.0, time stamp: 0x65a80000
Faulting module name: EmbeddedBrowserWebView.dll, version: 126.0.2592.68, time stamp: 0x66736afe
Exception code: 0x80000003
Fault offset: 0x000000000039ac2d
Faulting process id: 0x1e70
Faulting application start time: 0x01dac74395589e33

This behavior is reproducible in any WebView2 app that opens a FileOpen Dialog

This is the sample repo that you can use to reproduce the crash.
https://github.com/RobertGlobant20/WebView2OpenDialogTester

Importance

Blocking. My app's basic functions are not working due to this issue.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

126.0.2592.69

SDK Version

1.0.2592.51

Framework

WPF

Operating System

Windows 10

OS Version

19045.4529

Repro steps

  1. Create a WebView2 app with contains a HTML Button (<button>Click Me</button>)
  2. In the onClick button event send a message to .NET with chrome.webview.postMessage("Message")
  3. In the .NET event handler that receive the message (.CoreWebView2.WebMessageReceived += ...) add code to open a OpenFileDialog:
OpenFileDialog openFileDialog = new OpenFileDialog();
 openFileDialog.Multiselect = true;
 openFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
 openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
 if (openFileDialog.ShowDialog() == true)
  1. Then when running the .NET WebView2 app click the HTML Button and wait some seconds until the app freeze (takes around 10 to 30 seconds to freeeze).
  2. If you check the Windows Event Viewer there will be a Error entry saying that EmbeddedBrowserWebView.dll failed.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

@RobertGlobant20 RobertGlobant20 added the bug Something isn't working label Jun 25, 2024
Copy link

Hi, @RobertGlobant20!

It seems that your issue contains the word "crash". If you have not already, could you attach a crash dump as a comment?

WV2 crash dumps are located in a subfolder of the app's user data folder (UDF): <UDF>\EBWebView\Crashpad\reports\. By default, the user data folder is created in the app's folder with a name like <App Exe Name>.exe.WebView2. Refer to Crash Diagnostics for more information.

Thank you for your cooperation!

@RobertGlobant20
Copy link
Author

Hi, @RobertGlobant20!

It seems that your issue contains the word "crash". If you have not already, could you attach a crash dump as a comment?

WV2 crash dumps are located in a subfolder of the app's user data folder (UDF): <UDF>\EBWebView\Crashpad\reports\. By default, the user data folder is created in the app's folder with a name like <App Exe Name>.exe.WebView2. Refer to Crash Diagnostics for more information.

Thank you for your cooperation!

There is no crash dump or stacktrace info due that is suddently closing.
I've checked EBWebView\Crashpad\reports\ and is empty
image

@RobertGlobant20
Copy link
Author

This is a GIF showing the behavior.
devenv_hHE1nts2Yz

@jfmnet
Copy link

jfmnet commented Jun 28, 2024

   Try this. This seems to solve the issue.

    public async Task<string> OpenFile()
    {
        //Make the method async
        //Add this line to make the method async
        await Task.Yield();

        var dialog = new OpenFileDialog();

        if (dialog.ShowDialog() == DialogResult.OK)
        {
            return dialog.FileName;
        }

        return "";
    }

@RobertGlobant20
Copy link
Author

Ok thanks for the help, I just tested and is working as expected.
Then as a resume of the fix seems that if we want to open a dialog from the js code (webpage being displayed in WebView2) we need to call async methods and use the await inside the code.

@RobertGlobant20
Copy link
Author

I will proceed to close this issue due that the solution provided fixed our problem.
Thanks

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

No branches or pull requests

3 participants