Bug 15500 - getGraphicsEvent consumes 100% CPU
Summary: getGraphicsEvent consumes 100% CPU
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Graphics (show other bugs)
Version: R 3.0.1
Hardware: All All
: P3 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2013-10-23 04:56 UTC by ari
Modified: 2013-10-24 13:24 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ari 2013-10-23 04:56:24 UTC
(NOTE: not sure if this affects Unix systems, but based on the code, below, it may. Regardless, I couldn't find a way to specify "all windows systems" above, for which I can confirm for the following bug.)
 
getGraphicsEvent() consumes 100% CPU (or, more accurately, 100% of one core) when invoked. This occurs on Windows Vista and 7, at the very least. This bug has been in many versions of R, including 3.0.2 (probably starting with the rewrite of getGraphicsEvent in R 2.12)

To reproduce:
win.graph()
getGraphicsEvent()

A simple solution:
 I did a bit of poking around and it would appear that the fault is in main/gevents.c, lines 140 - 157, which loops without pause. Adding a millisecond pause inside this loop would solve the problem and should not add a noticeable lag for the end-user. [ sleep(0.001) in gcc? ; might need "Sleep(1)" for Windows? ] (If one of the functions called in this loop pauses in other OS, then the problem is Windows-specific; otherwise it affects all implementations)
Comment 1 Duncan Murdoch 2013-10-23 09:10:03 UTC
Already fixed.

*** This bug has been marked as a duplicate of bug 15208 ***
Comment 2 Duncan Murdoch 2013-10-23 13:46:17 UTC
Sorry, I closed this too quickly.  It is indeed a different bug than 15208.  I don't see how to re-open it though...
Comment 3 Peter Dalgaard 2013-10-23 14:36:57 UTC
Not actually a duplicate according to DM
Comment 4 Duncan Murdoch 2013-10-24 13:24:59 UTC
I have now fixed this on Windows in R-devel.  It involved a lot of changes to other code as well (adding the R_WaitEvent function), so I won't backport it to R-patched until it has had a chance to be tested for a while.

The bug may still exist on other platforms, I will test as I can.