vscode-R icon indicating copy to clipboard operation
vscode-R copied to clipboard

plot in External browser trigger error of “useMethod”

Open liuhuoz opened this issue 1 year ago • 4 comments

Describe the bug When open an external browser (in case, Google Chrome), and draw a ggplot2 plot, the plot would not draw or in a wired way that elements are disrupted. Further, the terminal show message like:

Error in UseMethod("depth") :
  no applicable method for 'depth' applied to an object of class "NULL"
Error in grid.Call.graphics(C_upviewport, as.integer(n)) : 
  cannot pop the top-level viewport ('grid' and 'graphics' output mixed?)

However, after closing the browser, everything come back to normal.

Besides, directly using Radian without vscode and httpgd::hgd() function to open an external browser would not response such error.

To Reproduce here is my test code

data <- data.frame(
  x=rnorm(10), 
  y=rnorm(10)
)
data
p <- 
data %>% 
  ggplot(aes(x=x,y=y))+
  geom_point(size=10)
p

Steps to reproduce the behavior:

  1. draw a plot in vscode windows
  2. Click on 'Open in External Browser'
  3. draw another plot
  4. See error

Can you fix this issue by yourself? (We appreciate the help)

No

(If applicable) Please attach setting.json

{
    "r.rterm.option": [],
    "r.bracketedPaste": true,
    "files.associations": {
        "*.rmd": "markdown"
    },
    "r.rterm.windows": "D:\\miniconda3\\Scripts\\radian.exe",
    "r.rpath.windows": "D:\\R\\R-4.3.3\\bin\\R.exe",
    "r.plot.defaults.fullWindowMode": true,
    "r.workspaceViewer.showObjectSize": true,
    "r.lsp.use_stdio": true,
    "r.session.levelOfObjectDetail": "Detailed",
    "r.lsp.multiServer": false,
    "r.removeLeadingComments": true,
    "r.plot.useHttpgd": true,
    "r.session.useWebServer": true,
    "r.source.echo": true
}

Expected behavior the plot should be draw both in vscode window and browser

Screenshots If applicable, add screenshots to help explain your problem. You can show the keyboard contents by pressing F1 and Developer: toggle screencast mode

Environment (please complete the following information):

  • OS: Windows 11
  • VSCode Version: 1.85.2
  • VScode insider:1.89.0 (both stable and insider have this error)
  • R Version: 4.3.3
  • vscode-R version: 2.8.2

liuhuoz avatar Apr 16 '24 06:04 liuhuoz

The problem still exist after updating vscode-R to 2.8.5

liuhuoz avatar May 22 '24 14:05 liuhuoz

I have the same problem. Seems to have started since httpgd was "revived" and the plotting split out into unigd.

py9mrg avatar May 30 '24 11:05 py9mrg

I have the same problem. Seems to have started since httpgd was "revived" and the plotting split out into unigd.

Recently I draw the chord picture with the package "circlize" which is not a ggplot-based drawing system. When plotting in both vscode and bowser, it doesnt trigger any problem. However, when I draw other pic with ggplot2 in the same drawing dev, the error happened. It seems like a quite complex problem, and may relate to many packages, vscode-R and vscode itself.

liuhuoz avatar May 30 '24 11:05 liuhuoz

#https://github.com/nx10/httpgd/issues/184 Same problem

liuhuoz avatar Jun 06 '24 07:06 liuhuoz

Since the bug is related to a infrastructure problem about quartz graphics devices, but not a vscode-R or httpgd bug, I choose to close this issue. It may be a very long wating to fix the bug, because of its complexity. And for more info, please check those links. https://github.com/tidyverse/ggplot2/issues/3538 https://github.com/nx10/httpgd/issues/184 https://github.com/tidyverse/ggplot2/issues/5857

liuhuoz avatar Jul 19 '24 09:07 liuhuoz