[R-SIG-Mac] Embedded R, event loops, GUI events, and OS X

Simon Urbanek simon.urbanek at r-project.org
Wed Jul 2 16:06:23 CEST 2014


Miëtek,

On Jul 2, 2014, at 1:43 PM, Miëtek Bak <mietek at bak.io> wrote:

> Hello,
> 
> I’m helping with the development of an R-to-Haskell interoperability solution, called H.  The project allows Haskell functions to seamlessly call R functions and vice versa, making use of an embedded R interpreter.  H is developed in-house by Tweag I/O, and is soon to be open-sourced.
> 
> The project is stable on Linux and Windows, and I’m focussing on an OS X port.  Basic functionality is ready, but I’m having trouble with the GUI parts.  Specifically, any graph window, e.g. the one expected for `plot(cars)`, appears blank and unresponsive when triggered from H.
> 
> I think the issue lies between the H loop, the R event loop, and the Cocoa event loop.  So far, I’ve pored over “Writing R Extensions” (chapter 8, “Linking GUIs and other front-ends to R”), the R 3.1.0 sources, (`./src/library/grDevices/src/qdCocoa.m`), and the R.app 1.6.4 sources (`./RController.m`, `./REngine/RCallbacks.m`, `./REngine/RInit.m`, and `./REngine/REngine.m`).  I’ve also found interesting notes in the R.app `./ReadMe.txt`, but unfortunately, they no longer seem to be in sync with the code.
> 
> As I’ve seemingly hit a wall, I’m looking for advice.  Are any of the developers of the OS X port of R subscribed to this list?
> 

Yes.

In general, the trick is to make sure that you setup the R event loop. That is an extra step after initializing the embedded R. There is nothing special about the OS X port in that regard - as long as you run the R event loop all is well. It becomes more tricky if the app you use wants to use its own event loop - that can cause issues as you have to make sure the two loops mesh properly.

For more specific help you'll need to ask more specific questions - possibly with link to reproducible code.

Cheers,
Simon



> Thanks, and kind regards,
> 
> -- 
> Miëtek Bak
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> 



More information about the R-SIG-Mac mailing list