Skip to content

[Problem/Bug]: WebView2_11.remove_ContextMenuRequested returns ERROR_INVALID_STATE #5156

@sane-git

Description

@sane-git

What happened?

Hello dear WebView2-Team.

We're running a CDialog derived (MFC) application which hosts an instance of the WebView2 control.
During initialization of the WebView2 control we add several event handlers such as handlers for NavigationStarting, NavigationComplete and among others the ContextMenuRequested event.

In the dialog's OnDestroy message handler we do cleanup all that pertains to the WebView2 control including the removal of the event handlers mentioned in the previous paragraph.

The removal of the ContextMenuRequested event handler, however, leads to an ERROR_INVALID_STATE exception in the WebView control saying that The group or resource is not in the correct state to perform the requested operation.

Can you please take a look into the problem. A demo project is attached to this ticket.

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

133.0.3065.92

SDK Version

1.0.3124.44

Framework

Win32

Operating System

Windows 11

OS Version

10.0.26100 Build 26100

Repro steps

Please find a demo project attached to this ticket which you can use to reproduce this problem.

WebView2DialogDemo.zip

  1. Unzip the file
  2. Build the project
  3. Run the application
  4. Close the application

A messagebox with the error message The group or resource is not in the correct state to perform the requested operation. will pop up.
The error message is shown from the implementation's OnDestroy handler.
The error occurs in release builds and in debug builds.

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

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions