Microsoft/vscode

[webviews] deserializeWebviewPanel is not called when switching workspace trust to restricted

開放

#195,009 建立於 2023年10月6日

 (0 則留言) (0 個反應) (1 位負責人)TypeScript (39,847 個分叉)batch import
bughelp wantedwebview

倉庫指標

星標
 (184,936 顆星)
PR 合併指標
 (平均合併 11小時 43分鐘) (30 天內合併 1,000 個 PR)

描述

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

It is a custom extension which uses the Webview Api.

  • VS Code Version: 1.83.0
  • OS Version: Ubuntu 23.04

Steps to Reproduce:

  1. Use a webview which implements deserializeWebviewPanel
  2. Write console.log() statements when extension starts, ends, registers deserializeWebviewPanel and inside deserializeWebviewPanel
  3. Notice that on VSCode reload deserializeWebviewPanel is called, on workspace trust change to false the extension is reloaded but deserializeWebviewPanel is not called.
  4. The webview becomes unusable as it is not tracked anymore by the extension (trust=false restarts extension apparently).

First lines are printed when Reload Window is triggered. Last lines when switching the workspace trust to false: Screenshot from 2023-10-06 17-17-51

Possible workarounds:

Use onDidGrantWorkspaceTrust which is fired only when trusting the workspace + window.tabGroup Api (available from 1.67) to find the Panel and reuse it.

貢獻者指南