full cpu usage when minimized

I run across this strange problem in my app.
When the window is minimized, it take 100%cpu time ! ( of one of my 2 core that’s it)

after investigate, it seems that it’s the case even with pview !

I try with and without sync_video in my Config.prc, it’s the same result.

The other strange thing is, if I have “showfps” on, when I restore the window to its original size, it show something like 3000 fps for 1 sec.

So I assume that when the windows is minimized, instead of sleeping, panda still update like crazy, without checking the sync-video ?

is it a known bug ? a strange option in Config.prc ?
my config.prc

load-display pandagl

win-origin 50 50
win-size 800 600

fullscreen #f

framebuffer-hardware #t
framebuffer-software #f

depth-bits 16
color-bits 16
alpha-bits 0
stencil-bits 0
multisamples 0

notify-level warning
default-directnotify-level warning

model-path    $MAIN_DIR
model-path    /usr/share/panda3d
model-path    /usr/share/panda3d/models
sound-path    $MAIN_DIR
sound-path    /usr/share/panda3d
sound-path    /usr/share/panda3d/models
texture-path  $MAIN_DIR
texture-path  /usr/share/panda3d
texture-path  /usr/share/panda3d/models

want-directtools  #f
want-tk           #f

want-pstats 1           #f
task-timer-verbose 1
pstats-tasks 1

audio-library-name p3openal_audio

use-movietexture #t

hardware-animated-vertices 0

basic-shaders-only #f
record-gui-creation-stack 0
sync-video #t

my box:
ubuntu 8.10, panda3D 1.5.4, opengl drivers 180. ( same problem on windows xp)
8800GT, dual core 6000something

Hmm, you’re right–I see that too. Odd, that’s new. I’ll take a look.


So, the short answer is, I see the problem in pview, but not in Python. It turns out that pview has never had any code to limit the CPU utilization while the window is minimized, but ShowBase does, so I don’t know why you’re seeing that behavior in Python.

The longer answer is, it has nothing to do with rendering. In fact, minimizing the window can potentially increase your CPU utilization, because that means that it takes very little time to draw the frame, and the task loop can now run much faster. Since there’s nothing by default to slow down the task loop (especially when you take the graphics hardware out of the mix), it always runs as fast as the CPU will allow it to, which means it always consumes 100% of your available CPU.

Normally, consuming all of your CPU doesn’t really cause any problems. It’s not like it gets used up, after all. But it does make it hard to run other programs on the same machine, which is why ShowBase.py includes some special-case code to detect when the main window is minimized, and in that case only, it calls time.sleep(0.1) once per frame, which slows down the task loop and gives other programs a chance at the CPU.

So, that leaves the question as to why this call isn’t being made in your case. Try checking to see if base.mainWinMinimized is getting set for you.


The only case it fails is when the panda window is parented to other window, thus the minimize event is sent to the parent only. If it’s the case, it should be easy to propagate the event down to the child.

thank once again.
The problem was really on my side.
I was caching the windows -event ( to change the fov with the resizing of the window) and I forgot to change thing when minimized.
but that’s work now.