(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:
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)
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.
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.