Author Topic: add_ticks_callback cpu fan noise on windows  (Read 264 times)

howlerbr

  • Jr. Member
  • **
  • Posts: 10
    • View Profile
add_ticks_callback cpu fan noise on windows
« on: February 13, 2020, 06:40:45 PM »
hi, in my theme I was looking for a code to put a clock on it. I found this solution in other themes:

Code: [Select]

  local dt = fe.add_text( "", x*0.915, y*0.003, w*0.3, h*0.05 );
  dt.align = Align.Left;
  dt.charsize = x*0.02;
  dt.alpha = 230;

  dt.font = "Geforce Light";
 
  function update_clock( ttime ){
  local now = date();
  dt.msg = format("%02d", now.hour) + ":" + format("%02d", now.min );
}
//  fe.add_ticks_callback( this, "update_clock" );
}

But for some reason in windows after 30 seconds aproximately I noticed the cpu fan noise too loud. Trying to find the problem in my theme I commented out the line that updates the clock and now no noise... but also no clock.

Is there anything wrong with the code above or in the implementation of add_ticks_callback function in Windows?

Also the same noise problem when running videos (already converted them to use lower bit rate)

thanks!

zpaolo11x

  • Hero Member
  • *****
  • Posts: 906
    • View Profile
    • My deviantart page
Re: add_ticks_callback cpu fan noise on windows
« Reply #1 on: February 13, 2020, 10:54:56 PM »
The code is not wrong per se, the issue is that tick_callback is generated every 60th of a second, and if you don't have v-sync activated depending on your GPU hardware it can tick also at 100 or 200 times per second. Which means that your screen is redrawn and updated every 16 milliseconds, and this can cause a huge cpu performance hit, therefore fans start blowing to cool down the poor CPU.

i notice the same thing in my layout, and since you are using this for a clock you could try something to reduce the frequency at which the clock graphics are updated. For example you can use the date functions to check if a whole second is passed since the last update, so you don't redraw your screen 60 times per second but only once. I don't know There's also a command to get the time in milliseconds since the layout startup but this is not really useful here because it's not related to the actual time.

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1160
    • View Profile
Re: add_ticks_callback cpu fan noise on windows
« Reply #2 on: February 14, 2020, 04:49:19 AM »
You can try using an estimated delta value to redraw the frame and potentially reduce load. I created a delta class in my fork. Curious if it reduces load for you.

howlerbr

  • Jr. Member
  • **
  • Posts: 10
    • View Profile
Re: add_ticks_callback cpu fan noise on windows
« Reply #3 on: February 14, 2020, 05:01:35 PM »
I'm using a notebook with AMD Radeon, how do I set V-Sync? Is it in the radeon settings utility?