Still fighting with "grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, polygon edge not found" error

Hello,
(Appologies upfront for the length message, but it is a long battle that I'm fighting in and would like to provide all data that I gathered so far.)

The post is related to an older thread/discussion (see here) that I started a few months ago, but quickly closed it with a message that the problem was solved (and how).
Unfortunately it seems that I did not really saved it, and I will appreciate any help with figuring it out. It seems to be related to a concurrency problem when rendering ggplot objects, maybe not in the library but in the quartz system used to plot them --- I don't know, but I am fighting with it for quite a long time, and will really appreciate any help on that.

Here is what's going on:

  1. More and more often, after charting for a while with ggplot, I start getting the:
    grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, polygon edge not found
    error. From that point on, I could not find any way to recover from it except of rebooting my computer. (I have a Mac that I use very heavily, so a reboot has a really high time cost for me)

  2. The problem only affect ggplot charts rendering --- if I pipe the plot object to plotly object via ggplotly, the chart is rendered and can be viewed on the View panel in RStudio, or on a browser if the R session is outside of RStudio.

  3. Importantly, I am using R and charting very heavily, at a high level of concurrency: meaning that I have multiple R sessions that are all generating and rendering plots every few seconds or minutes; some of these sessions are in RStudio windows, some are of jobs that they spawn, and some are interactive R sessions that I manually run from the shell. Each session uses only one graphical device (dev.curr is fixed and I never create or switch to another device), but obviously each session has a separate graphical device.

The problem occurs sporadically, at some random time during the day when plots are being generate.
Once it occurs, it affects all sessions, and none can render any ggplot objects anymore. This is true for even new sessions that are opened after that point. In fact, I can close all RStudio windows, kill all jobs, exit all existing R sessions, and a new R session will still not be able to plot any ggplot object that I create --- as simple as it may be.

Please, share any ideas or solutions that you may have.

Ideally, I would like to avoid the problem altogether. I do need the concurrency, though; my sessions monitor and plot different live processes, and it would be wrong to run it all in one session (there may be a middle ground, though, see comments at end).

Even if it is the problem is too subtle to reproduce/debug, I'd at least want to be able to recover from it and be able to plot again without restarting my computer, which introduces a very high overhead if needed to be done every few days.

Two final comments:

  • If it comes to it, I may be able to serialize only the rending by have a single r session that only read/get ggplot objects generated by the other objects, and plot each on a different graphical device. Basically implement a client server system for plotting. I really rather avoid it, and I'm not even sure that it will solve the problem.
  • Another option that I did not try is to render the objects in shiny apps that are invoked from the R sessions. Once again, it will require more work, and I do not know if it will solve the problem.

Any ideas will be highly appreciated.

Thanks!

Had the same problem. Disappeared when I re-installed X11 https://www.xquartz.org. Now I just get an R studio disconnect error one in a while.

1 Like

Thanks much, will give it a shot, and update later. Thanks!

Hmm, unfortunately that by itself did not help. I closed all quartz windows, exited quartz, reinstall it (and checked that at least the Quartz.app modified date was updated), but the problem sustain. I did not try to reboot, but, again, I know that once I do that everything will work --- for a while, until I hit it again.
Simple question: do you remember if you rebooted after reinstallation before the problem was resolved? if yo didn't then I know that what worked for you doesn't work for me, but if you did, I cannot compare pre-reboot, and running for a few days, hopping that maybe this time it won't happen.

Thanks!

Update: I also upgraded to R version 4, and then reinstall many libraries (including ggplot2, that was on the latest version before, but still), and then the problem disappeared (no restart), at least for now!
Thanks again, @dirkdittmer, for the suggestion, it's probably the combination of the re-installation of Quartz and many of the graphic related packages, but hopefully it will sustain. I'm marking the issue as closed (solution), hopefully will not need to re-open it again.

Thanks again!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.