jvcleave / ofxImGui

Use ImGui in openFrameworks
296 stars 124 forks source link

CPU ressource leak ? #4

Open martialgallorini opened 8 years ago

martialgallorini commented 8 years ago

Hello,

i have just built a basic UI with some sliders and buttons without binding anything to it.

strange behavior : when the app has the focus, everything seems ok and CPU usage is around 5% on my core i7 quad cores. but as soon as the app is out of focus (i.e. i bring my chrome browser in front) then my ImGui app suddenly eat 97% of CPU, computer gets hot and fan is going mad.

A similar app built with ofxUI and bind to OSC precesses uses around 2,7 % of CPU no matter what

jvcleave commented 8 years ago

Weird - I am assuming on a Mac?

martialgallorini commented 8 years ago

yes on a macbook pro 15" late 2013

i will try under linux

martialgallorini commented 8 years ago

less effect under Ubuntu 14.04.3 but still...

also, same problem with the provided example.

jvcleave commented 8 years ago

@martialgallorini I created a test branch for this. The CPU use certainly is reduced when minimized but I am unsure of the implication on any background tasks (i.e. OSC, image processing, etc)

https://github.com/jvcleave/ofxImGui/tree/minimized-cpu-test

martialgallorini commented 8 years ago

hey. I gave it a shot. It is a bit better but issue persists.

As i said, when app is in the front, it uses much less CPU.

ofApp in front and Chrome in the back :

capture d ecran 2015-12-15 a 17 23 05

Chrome in front with ofApp in the back :

capture d ecran 2015-12-15 a 17 24 02

oF v09 on Macbook Pro core i7 under OSX El Capitan

jvcleave commented 8 years ago

The code is only concerned when the app is minimized. GLFW_FOCUSED (as opposed to GLFW_ICONIFIED ) may work better for background

martialgallorini commented 8 years ago

Yes i see. This sure is better. But this doesn't solve the problem...

Do you think this is related to the OS ?

jvcleave commented 8 years ago

It may partially be related to the OS. Also depends if OF has anything to assist with dealing with app focus in place.

Why doesn't it solve the problem?