MicrosoftEdge / MicrosoftEdge/WebView2Feedback

[Problem/Bug]: Program crashes when calling host object

Open
#5,024 4 comments 0 reactions 1 assignee View on GitHub

@prija-microsoft is already working on this.

Since Jun 16, 2025.

bug
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

What happened?

The program crashed when an array was passed into the parameter to call the host object and return the parameter.

Importance

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

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

131.0.2903.112

SDK Version

1.0.2903.40

Framework

Win32

Operating System

Windows 11

OS Version

No response

Repro steps

Create CoreWebView2 on the host side, add the host object fn through AddHostObjectToScript, and the object will return the passed-in parameters as they are, then OpenDevToolsWindow, run the code on the console.

This is a simple ahk implementation.

; https://github.com/thqby/ahk2_lib
#Include <WebView2\WebView2>
g := Gui()
g.Show('w800 h600')
wvc := WebView2.create(g.Hwnd)
cwv := wvc.CoreWebView2
cwv.AddHostObjectToScript('fn', v => v)
cwv.OpenDevToolsWindow()
await chrome.webview.hostObjects.fn(123) // 123
await chrome.webview.hostObjects.fn('abc') // 'abc'
await chrome.webview.hostObjects.fn({a:1,b:2}) // {a:1,b:2}
await chrome.webview.hostObjects.fn({a:[12,34]}) // {a:[12,34]}
await chrome.webview.hostObjects.fn(Promise.resolve(0)) // {}, the return value is different from the incoming value.
await chrome.webview.hostObjects.fn(new Map()) // {}, the return value is different from the incoming value.
await chrome.webview.hostObjects.fn([12,34]]) // [null,null], after a few seconds, the program crashed.
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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.