Bug#445204: Fix rss-glx screensavers consuming 100% CPU

2008-09-04 Thread Jussi Kivilinna

Yes, new upstream version 0.8.2 has been released which does about the same.

Quoting Ari Pollak [EMAIL PROTECTED]:


Have you submitted this upstream? I'd rather get it accepted there.

On Thu, 2008-08-28 at 11:37 +0300, Jussi Kivilinna wrote:

Hello,

Here's debdiff against rss-glx-0.8.1-11 with patchset to
  1. fix frame time calculations when frame limiter is enabled.
  2. allow --nice/--max-fps options to disable frame limiter.
  3. enable frame limiter and set default fps 50.











--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#445204: Fix rss-glx screensavers consuming 100% CPU

2008-08-28 Thread Jussi Kivilinna
Hello,

Here's debdiff against rss-glx-0.8.1-11 with patchset to
  1. fix frame time calculations when frame limiter is enabled.
  2. allow --nice/--max-fps options to disable frame limiter.
  3. enable frame limiter and set default fps 50.

With 1. and 3. rss-glx screensavers doesn't hog 100% CPU anymore,
patch 2. is because --nice/--max-fps were there only to enable
frame limiter and couldn't be used to disable.

 - Jussi
diff -u rss-glx-0.8.1/debian/control rss-glx-0.8.1/debian/control
--- rss-glx-0.8.1/debian/control
+++ rss-glx-0.8.1/debian/control
@@ -2,7 +2,7 @@
 Section: x11
 Priority: optional
 Maintainer: Ari Pollak [EMAIL PROTECTED]
-Build-Depends: debhelper ( 4.0.0), libx11-dev, libxt-dev, libgl1-mesa-swx11-dev | libgl-dev, libglu1-mesa-dev | libglu-dev, libglew1.5-dev | libglew-dev, libopenal-dev, libalut-dev, libmagickwand-dev, libtool, pkg-config
+Build-Depends: debhelper ( 4.0.0), dpatch, libx11-dev, libxt-dev, libgl1-mesa-swx11-dev | libgl-dev, libglu1-mesa-dev | libglu-dev, libglew1.5-dev | libglew-dev, libopenal-dev, libalut-dev, libmagickwand-dev, libtool, pkg-config
 Standards-Version: 3.6.1
 
 Package: rss-glx
diff -u rss-glx-0.8.1/debian/rules rss-glx-0.8.1/debian/rules
--- rss-glx-0.8.1/debian/rules
+++ rss-glx-0.8.1/debian/rules
@@ -2,6 +2,8 @@
 # Sample debian/rules that uses debhelper.
 # GNU copyright 1997 to 1999 by Joey Hess.
 
+include /usr/share/dpatch/dpatch.make
+
 # Uncomment this to turn on verbose mode.
 #export DH_VERBOSE=1
 
@@ -34,7 +36,7 @@
 
 build: build-stamp
 
-build-stamp:  config.status
+build-stamp: patch-stamp config.status
 	dh_testdir
 
 	# Add here commands to compile the package.
@@ -43,7 +45,7 @@
 
 	touch build-stamp
 
-clean:
+clean: unpatch
 	dh_testdir
 	dh_testroot
 	rm -f build-stamp 
diff -u rss-glx-0.8.1/debian/changelog rss-glx-0.8.1/debian/changelog
--- rss-glx-0.8.1/debian/changelog
+++ rss-glx-0.8.1/debian/changelog
@@ -1,3 +1,12 @@
+rss-glx (0.8.1-11jk1) experimental; urgency=low
+
+  * Fix rss-glx screensavers hogging 100% CPU (Closes: #445204)
+- Fix frame time calculations when frame limiter is enabled
+- Allow --nice and --max-fps options to be used to disable frame limiter
+- Enabled frame limiter by default with FPS set to 50.
+
+ -- Jussi Kivilinna [EMAIL PROTECTED]  Thu, 28 Aug 2008 11:24:15 +0300
+
 rss-glx (0.8.1-11) experimental; urgency=low
 
   * Apply patch to build with new ImageMagick in experimental
only in patch2:
unchanged:
--- rss-glx-0.8.1.orig/debian/patches/00list
+++ rss-glx-0.8.1/debian/patches/00list
@@ -0,0 +1,3 @@
+01_fix-frame-time-calculations.dpatch
+02_expand-driver_cpp-opts-to-allow-disabling-frame-limiter.dpatch
+03_enable-frame-limiter-by-default-with-fps-50.dpatch
only in patch2:
unchanged:
--- rss-glx-0.8.1.orig/debian/patches/01_fix-frame-time-calculations.dpatch
+++ rss-glx-0.8.1/debian/patches/01_fix-frame-time-calculations.dpatch
@@ -0,0 +1,136 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 01_fix-frame-time-calculations.dpatch by Jussi Kivilinna [EMAIL PROTECTED]
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Old frame time calculation stored current time of frame to local 
+## DP: variable 'now'. Problem was that 'now' was used and overwritten other 
+## DP: places (idle sleep code and fps display) and as result calculated frame 
+## DP: times were too short, when frame limiter was activated.
+
[EMAIL PROTECTED]@
+
+diff --git a/src/driver.cpp b/src/driver.cpp
+index 0b48d0f..3e7ddb8 100644
+--- a/src/driver.cpp
 b/src/driver.cpp
+@@ -148,13 +148,21 @@ void clearBuffers() {
+ 	}
+ }
+ 
++static double getSeconds(void)
++{
++	struct timeval now;
++
++	gettimeofday (now, NULL);
++	return (double)now.tv_sec + now.tv_usec / 100.0;
++}
++
+ void mainLoop (void)
+ {
+ 	int bFPS = False;
+ 	XEvent event;
+ 	Atom XA_WM_PROTOCOLS = XInternAtom (XStuff-display, WM_PROTOCOLS, False);
+ 	Atom XA_WM_DELETE_WINDOW = XInternAtom (XStuff-display, WM_DELETE_WINDOW, False);
+-	struct timeval then, now, fps_time;
++	double currFrameTime, currFrameTimeSoFar, currFrameStartTime, prevFrameStartTime, now, fps_time;
+ 	int fps = 0;
+ 
+ 	if (!rootWindow) {
+@@ -163,10 +171,16 @@ void mainLoop (void)
+ 
+ 	clearBuffers();
+ 
+-	gettimeofday (now, NULL);
+-	int frameTimeSoFar = 0;
++	currFrameStartTime = getSeconds();
+ 	while (!signalled) {
+-		hack_draw (XStuff, (double)now.tv_sec + now.tv_usec / 100.0f, frameTimeSoFar / 100.0f);
++		prevFrameStartTime = currFrameStartTime;
++		currFrameStartTime = getSeconds();
++		currFrameTime = currFrameStartTime - prevFrameStartTime;
++
++		if (currFrameTime  0.0)
++			currFrameTime = 0.01;
++
++		hack_draw (XStuff, currFrameStartTime, currFrameTime);
+ 
+ 		glXSwapBuffers (XStuff-display, XStuff-window);
+ 
+@@ -174,16 +188,14 @@ void mainLoop (void)
+ 			if (fps != -1)
+ fps++;
+ 
+-			gettimeofday (now, NULL);
+-
+-			if (now.tv_sec  fps_time.tv_sec) {
++			now = getSeconds();
++			if (now = fps_time + 1.0