Skip to content

WebView port mapping not working under Remote SSH #102449

Description

@renkun-ken
  • VSCode Version: 1.47.0, 1.48.0-insider
  • OS Version: macOS 10.15.5
  • Remote SSH: Ubuntu 18.04

Steps to Reproduce:

  1. Install vscode-R extension.
  2. Set r.sessionWatcher to true, and reload vscode.
  3. Use Remote-SSH to connect to remote Linux server (where R is installed).
  4. Install vscode-R extension to remote server.
  5. Create R terminal and an R session is started
  6. Run ?get

It starts an http server that provides the R documentation, and a VSCode
WebView should show up by the following extension code.

functionshowBrowser(url: string,title: string,viewer: string|boolean){console.info(`[showBrowser] uri: ${url}, viewer: ${viewer}`);if(viewer===false){env.openExternal(Uri.parse(url));}else{constport=parseInt(newURL(url).port);constpanel=window.createWebviewPanel('browser',title,{preserveFocus: true,viewColumn: ViewColumn[String(viewer)],},{enableScripts: true,retainContextWhenHidden: true,portMapping: [{extensionHostPort: port,webviewPort: port,},],});panel.webview.html=getBrowserHtml(url);}console.info('[showBrowser] Done');}functiongetBrowserHtml(url: string){return`<!DOCTYPE html><html lang="en"><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> html, body { height: 100%; padding: 0; overflow: hidden; } </style></head><body> <iframe src="${url}" width="100%" height="100%" frameborder="0" /></body></html>`;}

When viewer="Active", the WebView cannot be shown properly with the latest release and insider of VSCode. The iframe content is empty.

<iframesrc="http://127.0.0.1:22784/library/base/html/get.html" width="100%" height="100%" frameborder="0"></body></html></iframe>

However, if I run the following in R

.vsc.browser("http://127.0.0.1:22784/library/base/html/get.html", viewer=FALSE)

which basically calls showBrowser with viewer=false, then a local web browser is open by env.openExternal(Uri.parse(url)); the web page is properly shown. Only after this, I call ?get, or equivalently

.vsc.browser("http://127.0.0.1:22784/library/base/html/get.html", viewer="Active")

The WebView could be properly shown.

I guess the port mapping of WebView via Remote SSH somehow is not working and it works with the port mapping enabled by env.openExternal(Uri.parse(url)). Everything works well if the same is done locally.

Related: REditorSupport/vscode-R#380.

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

author-verification-requestedIssues potentially verifiable by issue authorbugIssue identified by VS Code Team member as probable bugelectronIssues and items related to Electronupstream-issue-linkedThis is an upstream issue that has been reported upstreamverifiedVerification succeededwebviewWebview issues

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions