MicrosoftEdge / MicrosoftEdge/WebView2Feedback
[Problem/Bug]: StateChanged handler never called
@ambikakunnath is already working on this.
Since Jul 6, 2026.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
What happened?
When watching downloads (add_DownloadStarting) the state never changes and stay forever "in progress". My code was running perfectly well with v144, but doesn't run anymore with 147, 148 and 150.
Edit : it's still working perfectly when downloading while inside the page (i.e. no window.open or taget="_blank"_). I don't even need to check state, juste configuring the listener and waiting for completness is enough.
Importance
Important. My app's user experience is significantly compromised.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
150.0.4078.48
SDK Version
1.0.2792.45
Framework
Win32
Operating System
Windows 11
OS Version
26100.8655
Repro steps
Add a download listener and start downloading a file (only tried a small one).
Microsoft::WRL::ComPtr<ICoreWebView2_4> coreWebView2_4;
if (SUCCEEDED(m_mainWebView.As(&coreWebView2_4))) {
hRes = coreWebView2_4->add_DownloadStarting(Callback<ICoreWebView2DownloadStartingEventHandler>(
[this](ICoreWebView2* webview, ICoreWebView2DownloadStartingEventArgs* args) -> HRESULT
{
Microsoft::WRL::ComPtr<ICoreWebView2DownloadOperation> downloadOperation;
if (SUCCEEDED(args->get_DownloadOperation(&downloadOperation))) {
HRESULT hRes = S_OK;
EventRegistrationToken stateChangedToken;
hRes = downloadOperation->add_StateChanged(Callback<ICoreWebView2StateChangedEventHandler>(
[this, stateChangedToken, downloadOperation](ICoreWebView2DownloadOperation* downloadOperation, IUnknown* args) -> HRESULT {
COREWEBVIEW2_DOWNLOAD_STATE downloadState;
HRESULT hRes = (downloadOperation->get_State(&downloadState));
if (SUCCEEDED(hRes) && downloadState != COREWEBVIEW2_DOWNLOAD_STATE_IN_PROGRESS) {
downloadOperation->remove_StateChanged(stateChangedToken);
// do something ... NEVER GETS CALLED :'(
}
return S_OK;
}
).Get(), &stateChangedToken);
INT64 bytesReceived, totalBytes;
downloadOperation->get_BytesReceived(&bytesReceived);
downloadOperation->get_TotalBytesToReceive(&totalBytes);
// HERE !!!
// bytesReceived == totalBytes but downloadState is still "in progress"
// and stateChanged listener never gets called afterwards
// (even if I keep a reference to downloadOperation into a member variable)
COREWEBVIEW2_DOWNLOAD_STATE downloadState;
hRes = (downloadOperation->get_State(&downloadState));
if ((SUCCEEDED(hRes) && downloadState != COREWEBVIEW2_DOWNLOAD_STATE_IN_PROGRESS)) {
downloadOperation->remove_StateChanged(stateChangedToken);
args->put_Handled(TRUE);
// do something ...
}
}
return S_OK;
}).Get(), &m_downloadStartingToken);
RETURN_IF_FAILED(hRes);
}
Http request :
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
Regression in newer Runtime
Last working version (if regression)
144
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.