Skip to content

Problems with Rcmdr via XQuartz on OSX Mavericks

47 messages · Brian Ripley, Reijo Sund, Jonathan Chapman +7 more

Messages 26–47 of 47

#
Hi Rob,

You've just answered my next question! I was holding off to give you a
chance to address the issue directly in R.app.

Is there any reason for me, at least for the time-being, not to do this from
the Rcmdr via system()? I just tried, and that seems to work. If necessary,
I could check for the existence and (if it exists) the current state of this
key, and restore that when the Commander() exits. Of course, if you plan to
address the issue directly soon, it doesn't make sense for me to do so.

Thanks again for your help.

John
current
always
off
<jfox at mcmaster.ca>
understanding
dalgaard
Robert J
takes to see
demo(tkfaq),
wonder if anyone
7:29 AM, Simon
2013, at 11:41 AM,
upgraded to XQuartz
Peter's response
version
list
R-SIG-Mac at r-project.org
Copenhagen
Frederiksberg,
https://stat.ethz.ch/mailman/listinfo/r-sig-
#
Hi John,

If it's not too much work, I would implement it in Rcmdr because I don't know if there are other consequences of App Nap, so until the dust settles using the defaults system might be ok.

Regards,
Rob J. Goedman
goedman at icloud.com
On Nov 24, 2013, at 8:30 AM, John Fox <jfox at mcmaster.ca> wrote:

            
#
Hi Rob,

OK -- thanks. I'll do that in the development version of the package on
R-Forge when I have a chance, likely sometime this week. I'll then post a
message to this list.

Best,
 John
3 days later
#
Hi Rob,

I had some time today and so I started to implement this solution in the
Rcmdr. I first tested whether setting

  system("defaults write org.R-project.R NSAppSleepDisabled -bool yes")

fixes the problem; I verified via 

  system("defaults read org.R-project.R NSAppSleepDisabled")

that the key was in fact set properly. 

I'm afraid that even with NSAppSleepDisabled set, the Rcmdr still freezes
periodically. Whatever is going on is probably more complicated than
power-saving.

Best,
 John
#
On 28 Nov 2013, at 01:46 , John Fox <jfox at mcmaster.ca> wrote:

            
Hmm. The tkfaq issue seems to have gone away for me. You did remember to restart R.app after setting the key?

-pd

  
    
#
Dear Peter,

On Thu, 28 Nov 2013 12:00:31 +0100
peter dalgaard <pdalgd at gmail.com> wrote:
I didn't "remember" to restart R.app because I didn't know that it was necessary to do so. In fact, the code that I wrote, but didn't commit, for the Rcmdr carefully resets the key to its previous state or deletes it if it didn't previously exist when the Commander is closed.

I think that you've almost surely identified my problem, but the solution also raises a question about what to do. I'm reluctant to have the Rcmdr make a permanent change to users' OS settings. I guess that I could detect whether the NSAppSleepDisabled key is set and pop up a dialog box if it isn't, offering to make the change, and suggesting that the user restart R.app. (BTW, is there an easy way to check whether R is running in R.app or a terminal?) Wouldn't it be better to handle this issue in R.app or even in tcltk, however?

If restarting R.app after setting the NSAppSleepDisabled key doesn't work for me, I'll then pursue Rob's suggestions.

Thanks for this,
 John
#
On 28 Nov 2013, at 14:38, John Fox <jfox at mcmaster.ca> wrote:

            
Look at svMisc::isAqua(), which uses indeed .Platform$GUI returning "Aqua" on R.app or "X11" on R under a terminal. I am not sure, however, that R on a terminal returns *always* "X11".
Best,

Philippe
[?]
#
Dear Philippe,

Thanks for this. Since I can already tell when R is running under Mac OS X, that should solve the problem of differentiating R.app and R running in a terminal.

Best,
 John

On Thu, 28 Nov 2013 14:54:52 +0100
Philippe Grosjean <phgrosjean at sciviews.org> wrote:
]
#
On 28 Nov 2013, at 14:38 , John Fox <jfox at mcmaster.ca> wrote:

            
I suspect that this particular option also affects people running simulations from R.app, so that the natural state really should be "disabled" and you need not have qualms about tampering with it. Presumably, we could do the disabling on install. If people have strong reasons to aggressively preserve battery power, they could just turn it back on. 

I think Rob put on his todo list to figure out whether/how you change the setting in an active process, which would open up other possibilities.

-pd
#
Hi, and Happy Thanksgiving for those that celebrate it!

If Peter is right (and I expect he is, but will experiment a bit more if the setting can be updated while R.app is running and take effect immediately), I would suggest for now folks just use 'defaults ...' from a terminal window if they encounter these issues.

Once we understand better what might be affected by allowing the sleep mode we can possibly refine that approach.

Regards,
Rob


Sent from Rob Goedman's iPad ...
#
Dear Rob and Peter,

Thanks for the latest clarifications.

I think that I'll modify the Rmcdr installation notes to suggest either using the Rcmdr from R in a terminal window or setting the NSAppSleepDisabled key permanently in a terminal window -- and hope that in the longer term the problem is solved generally for R.app.

Best,
 John

On Thu, 28 Nov 2013 06:35:12 -0800
Robert J Goedman <goedman at icloud.com> wrote:
------------------------------------------------
John Fox
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/
#
Hi Rob,

Please don't feel the need to apologize -- I greatly appreciate your help
with this problem, and all the Mac-related problems with which you've
helped.

Best,
 John
John Fox
I started
whether setting
org.R-project.R
verified via
org.R-project.R
properly.
going on is
gone away
I
my
#
On Nov 28, 2013, at 8:38 AM, John Fox <jfox at mcmaster.ca> wrote:

            
Yes, check for R_GUI_APP_VERSION env var.

But let me say that what has been proposed is very heavy-handed to say it mildly - changing user's configuration files is not something that should be done without user's consent (if at all) - and AFAIK you're not allowed to do it if you plan to put this on CRAN. In addition, it's trying to swat the symptom with a hammer, it doesn't solve the problem (which is why doesn't tcltk wake up sleep with its activity).
Yes, it should be handled in either of the two - if this problem is tcltk-specific then tcltk should wake up the sleep, if it is something that affects other R code as well, then it may need to be handled in the R event loop.

Cheers,
Simon
#
Dear Simon,
Well, I was proposing to ask for the user's consent (I thought that was
clear from my message), but, as I said, it would be better to fix this in
either tcltk or R.app, depending upon the nature of the problem. So I think
that we're in agreement. 

Also, I mentioned in a subsequent message that, for the time-being, I'll
simply put a note about NSAppSleepDisabled in the Rcmdr Mac OS X
installation notes.

Best,
 John
can
is
the
be to
it
will
switch
in the
<goedman at icloud.com> wrote:
peter
16:42 ,
long it
library(tcltk);
me
Goedman
goedman at icloud.com
2013, at
Nov 20,
I
Please read
[[alternative HTML
mailing
Professor,
Statistics,
2000
Priv:
deleted]]
#
On 29 Nov 2013, at 16:35 , Simon Urbanek <simon.urbanek at r-project.org> wrote:

            
On the other hand, the OS is also acting very heavy-handed here! Try this
and go surf the net or something while you wait. The time per iteration shoots up by a factor of 5-6 as R.app goes into App Nap. I.e., the problem is not confined to tcltk.
Looks like it is that latter. Until we figure out how to do that, I think we need to prepare to tell users to set NSAppSleepDisabled, if they want to do something computationally intensive (and be able to go for a cup of coffee in the meantime). Of course it is nicer, OS-wise, to leave App Nap enabled, but it reduces the energy footprint of an inactive R.app from only about 1.5 to nearly 0.0, compared to about 100 when R is actually working.
#
This does not happen for me provided R.app is visible.  From

https://developer.apple.com/library/mac/releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_9.html

'An app is considered to be a candidate for sleep if:

     It is not visible?if all of an app?s windows are either hidden by 
other windows or minimized in a hidden dock, and the app is not in the 
foreground

(other necessary conditions)'.

which if accurate indicates that keeping the R.app console unhidden 
should suffice.
On 30/11/2013 10:59, peter dalgaard wrote:

  
    
#
Dear Brian,

Keeping R.app visible should deal with the case of a long computation as long as users are conscious of the problem, but it's likely that users of the Rcmdr will normally cover up the R.app window or minimize it.

 Best,
 John

On Sat, 30 Nov 2013 11:37:19 +0000
Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:
------------------------------------------------
John Fox
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/
#
On 30 Nov 2013, at 12:37 , Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:

            
Some experimenting indicates that R.app will nap  with a partially exposed window, if there is no change to the exposed part of the window. If the top right corner is obscured by the Activity Monitor and I change the test command to not generate output, I see
[1]  5.853  3.607  3.118  3.037  3.012  2.983  2.962  2.978  2.949  2.956
[11]  2.957 19.882 24.386 26.441 25.563 27.452 21.195 20.823  3.012  2.976
[21]  2.965  2.966  2.969  2.945  3.057  2.958  2.942  2.971  2.976  2.936
[31]  2.978  2.960  2.991  2.991  2.994  3.021  2.991  2.974  3.005  2.985
[41]  3.006  2.991  3.033  3.017  2.978  3.012  2.987  2.997  2.995  3.053

(I got bored and woke it after a couple of minutes, at iteration 18).

It doesn't happen if it is the bottom right corner that is obscured, so that the spinning "I'm working" symbol is visible, so I suppose the logic is tied to window updates.

  
    
#
On 30 Nov 2013, at 16:58 , Robert J Goedman <goedman at icloud.com> wrote:

            
One item: I found that there is a tick box "Prevent App Nap" available via Get Info for applications (secondary click in the Applications folder), which is somewhat more intuitive that the "defaults write ..." route. If we make your change, will the same box appear, just selected by default?