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

[CustomTextEditor extension] onDidReceiveMessage and resolveCustomTextEditor are not called after restarting extension host #150135

Closed
Ark-kun opened this issue May 22, 2022 · 2 comments
Assignees
Labels
custom-editors Custom editor API (webview based editors) *duplicate Issue identified as a duplicate of another issue(s)

Comments

@Ark-kun
Copy link

Ark-kun commented May 22, 2022

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.67.2
  • OS Version: Windows 10

Steps to Reproduce:

TL/DR:
When restarting extension host, the CustomTextEditor the WebView HTML is somehow preserved and reloaded, but the onDidReceiveMessage subscriptions are lost (and resolveCustomTextEditor which sets up the subscription is not called).

  1. Open the https://github.com/microsoft/vscode-extension-samples/tree/0d36653b0da5041f49fe049e34f6d8671f8e1002/custom-editor-sample
  2. Optionally modify catScratchEditor.ts: Add console.log("resolveCustomTextEditor called"); as the first line of the resolveCustomTextEditor function. Add console.log("onDidReceiveMessage called"); as the fist line of the webviewPanel.webview.onDidReceiveMessage handler.
  3. Create and fully open a text file dummy.txt.
  4. Click on a dummy.cscratch file to preview it in custom editor
  5. Notice "resolveCustomTextEditor called" in dev tools console logs.
  6. Open command palette and call "Restart extension host"
  7. Observe that the extension has activated.
  8. Observe that the extension webview is visible.
  9. Switch tab to dummy.txt file
  10. Switch tab back to the dummy.cscratch tab.
  11. Observe that the console logs do not have "resolveCustomTextEditor called" or "onDidReceiveMessage called"
  12. Observe that the extension webview reloads and HTML becomes visible again (despite no calls to resolveCustomTextEditor and no webviewPanel.webview.html = assignments).
  13. The extension is now broken: The webview tries to send messages but onDidReceiveMessage handler is not getting called anymore and resolveCustomTextEditor which could re-install the handler is never called either.
2022-05-22.14-36-00.mp4

P.S. The VScode debug console has the following error message, but I do not know whether it's related:

stack trace: Error: Unknown webview handle:26fdf041-c36f-4df2-b28f-4e022706ff30
    at Vo.getWebview (vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1698:72568)
    at Vo.$postMessage (vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1698:71621)
    at d._doInvokeHandler (vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1705:13100)
    at d._invokeHandler (vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1705:12784)
    at d._receiveRequest (vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1705:11446)
    at d._receiveOneMessage (vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1705:10124)
    at vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1705:8233
    at S.invoke (vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:67:145)
    at s.fire (vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:67:1856)
    at u.fire (vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:83:19607)
    at g._receiveMessage (vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:83:24188)
    at vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:83:21722
    at S.invoke (vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:67:145)
    at s.fire (vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:67:1856)
    at s.acceptChunk (vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:83:16438)
    at vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:83:15568
    at Socket.O (vscode-file://vscode-app/c:/Users/Ark/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:3102:9329)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Socket.Readable.push (node:internal/streams/readable:228:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:199:23)
@vscodenpa
Copy link

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.67.2. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

@mjbvz
Copy link
Collaborator

mjbvz commented May 23, 2022

Duplicate of #122992

@mjbvz mjbvz marked this as a duplicate of #122992 May 23, 2022
@mjbvz mjbvz closed this as completed May 23, 2022
@mjbvz mjbvz added *duplicate Issue identified as a duplicate of another issue(s) custom-editors Custom editor API (webview based editors) labels May 23, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
custom-editors Custom editor API (webview based editors) *duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

3 participants