Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R Session Aborted with ragg + ggdag (+ ggraph) + RStudio #155

Closed
malcolmbarrett opened this issue Jan 30, 2024 · 5 comments
Closed

R Session Aborted with ragg + ggdag (+ ggraph) + RStudio #155

malcolmbarrett opened this issue Jan 30, 2024 · 5 comments

Comments

@malcolmbarrett
Copy link

So, I don't know where to file this issue exactly because I think this is several bugs working in concert. However, when I use the AGG backend in RStudio, I encounter session ending crash when running simple ggdag code

library(ggdag)
dag <- dagify(
  y ~ x + z2 + w2 + w1,
  x ~ z1 + w1,
  z1 ~ w1 + v,
  z2 ~ w2 + v,
  w1 ~~ w2,
  exposure = "x",
  outcome = "y"
)
ggdag_adjustment_set(dag)

Unfortunately, I can't replicate this with code using the ragg devices. However, I do not have a crash except when using it on RStudio and ragg on a Mac (e.g., I can't replicate in on Posit Cloud). However, I have had others be able to replicate it using those settings on their Macs. Everything works in the terminal and on CI checks, as well.

I do not really know the source of the bug, but it's got something to do with ggraph, and I think specifically to do with the cap-related code. ggdag uses ggraph in an unusual way, and it seems that in faceted plots with caps on edges, it is invoking some bug in ggraph that I can't replicate with true ggraph code (e.g. outside of ggdag). Then, this mystery bug is somehow getting caught up in the ragg-RStudio interface. That's as far as my detective skills have gotten me, and I'm not totally confident in that assessment.

I have experienced weird issues like this in the past but not conistently, and I've never been able to replicate them until now. I tried to install an old version of ragg but I'm having trouble compiling it, so I'm not sure if it's to do with recent versions or not.

I'm posting the issue here because of the confluence of ragg and ggraph, but also turning ragg on and off in RStudio was how I was finally able to replicate the issue.

I have the most recent version of everything in question, and I've tried various configurations of RStudio and R builds.

@thomasp85
Copy link
Member

I can replicate but only if I install the pre-compiled version of ragg from CRAN

@thomasp85
Copy link
Member

and only at certain sizes

@thomasp85
Copy link
Member

scratch that. I can also replicate it with own compilation at the right size

@thomasp85
Copy link
Member

A quick glance at the backtrace of the error reveals no calls to ragg at all but this could be due to the shadow device setup employed by RStudio

Best bet is probably to try and see if this is reproducible with ragg outside of RStudio by figuring out the size that makes it crash

@thomasp85
Copy link
Member

I can reproduce outside of RStudio and it is not confined to ragg

library(ggdag)
png('ragg1.png', width = 100, height = 100)
dag <- dagify(
  y ~ x + z2 + w2 + w1,
  x ~ z1 + w1,
  z1 ~ w1 + v,
  z2 ~ w2 + v,
  w1 ~~ w2,
  exposure = "x",
  outcome = "y"
)
plot(ggdag_adjustment_set(dag))
dev.off()

I'm moving this to ggraph as I have traced this to the line cutting algo, though I haven't figured out why it crashes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants