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

webview - message passing broken since 1.56.0 (extension->content window) #123822

Closed
tintinweb opened this issue May 13, 2021 · 3 comments
Closed
Assignees

Comments

@tintinweb
Copy link

tintinweb commented May 13, 2021

My extension tintinweb.graphviz-interactive-preview used to work fine until the 1.56.0 update arrived a couple of days ago. Users started to report an issue with the webview not rendering dot graphs anymore Consensys/vscode-solidity-auditor#72.

The extension renders dot graphs in a webview by loading an index.html (set via webview.html), waiting for a webview.postMessage({"command":"renderDot", "value":"<dotgraph>"}).

Now, this seems to be broken since 1.56.0 for some reason and I was trying to debug it without success. I tried to keep my code very much aligned with the examples but cannot seem to find the issue.

I am using webview.postMessage() to send messages to the content window and webview.onDidReceiveMessage(handler) to receive msgs from the content window but it looks like messages that I post do not arrive at the content window's message eventlistener but instead appear in webview.onDidReceiveMessage(). This hasn't happened before 1.56.0 and I assume this may be a breaking change introduced with the latest webview changes.

https://github.com/tintinweb/vscode-interactive-graphviz/blob/master/src/features/interactiveWebview.js#L69

Would be great if someone could verify what's happening here. Either I am somehow misusing the API or this might be a bug that could affect more extensions.

Note: My extension still receives messages from the contentWindow (e.g. save dot file from the menu, initiated from within the contentWindow), however, the contentWindow does not seem to receive any messages.

Version: 1.56.2
Commit: 054a9295330880ed74ceaedda236253b4f39a335
Date: 2021-05-12T17:44:30.902Z
Electron: 12.0.4
Chrome: 89.0.4389.114
Node.js: 14.16.0
V8: 8.9.255.24-electron.0
OS: Darwin x64 19.6.0

This used to work

Steps to Reproduce:

  1. get tintinweb.graphviz-interactive-preview
  2. open a graphviz dot file and hit cmd + shift + p -> interactive graphviz preview beside
  3. empty window (because content window is not receiving messages from the extension :/ they instead appear in the extensions message handler?! - see "unexpected command" in console (this is the extension not expecting the command that should have been posted to the contentwindow))
  4. clicking on the toolbar menu - save dot opens a vscode saveas dialog -> message from contentwindow to extension works fine

broken_webview2

@tintinweb
Copy link
Author

tintinweb commented May 14, 2021

closed / invalid. one of my scripts defined a postMessage method which was the root cause of the problem. seems to be working now. thanks!

@maximgx
Copy link

maximgx commented May 14, 2021

it works now with 0.11

@jan-dolejsi
Copy link

jan-dolejsi commented May 14, 2021

@tintinweb, you are a genius. I was looking at this the whole week. Same issue - I too had a convenience function postMessage. I think you saved me another week of guessing.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants