MantisBT - MPfm
View Issue Details
0000283MPfmUI | Windows | Main Windowpublic2012-02-07 17:012012-02-08 16:48
ycastonguay 
ycastonguay 
immediatemajoralways
resolvedfixed 
0.5.1.0 
0.5.2.00.5.2.0 
0000283: The CPU usage is way too high when updating the UI with the current song position
I'm not sure starting which version the CPU usage has gone quite high, but it seems to be around 0.5.1.0.

It is especially worse with 0.5.2.0. It is related to updating the UI with song position information. The label update seem to eat quite a lot of CPU.

The update timer interval can be changed from 10ms to a higher value, but that would be at the cost of having really smooth rendering.
No tags attached.
related to 0000284resolved ycastonguay Cache font objects in every control 
Issue History
2012-02-07 17:01ycastonguayNew Issue
2012-02-07 17:01ycastonguayStatusnew => assigned
2012-02-07 17:01ycastonguayAssigned To => ycastonguay
2012-02-07 18:10ycastonguayTarget Version0.5.2.1 => 0.5.2.0
2012-02-07 18:13ycastonguayNote Added: 0000401
2012-02-07 18:13ycastonguayDescription Updatedbug_revision_view_page.php?rev_id=110#r110
2012-02-07 19:29ycastonguayRelationship addedrelated to 0000284
2012-02-07 21:19svnCheckin
2012-02-07 21:19svnNote Added: 0000403
2012-02-08 16:47ycastonguayNote Added: 0000404
2012-02-08 16:47ycastonguayStatusassigned => resolved
2012-02-08 16:47ycastonguayFixed in Version => 0.5.2.0
2012-02-08 16:47ycastonguayResolutionopen => fixed
2012-04-17 19:07ycastonguayCategoryMain Form => Main Window
2012-04-17 19:09ycastonguayCategoryMain Window => Window - Main
2012-04-21 09:57ycastonguayCategoryWindow - Main => UI - Windows - Main Window
2012-04-22 10:10ycastonguayCategoryUI - Windows - Main Window => UI | Windows | Main Window

Notes
(0000401)
ycastonguay   
2012-02-07 18:13   
After some testing with the label rendering, it seems that calling the OnPaintBackground event is what eats a lot of CPU, especially when the background is set as transparent.

In fact, filling a rectangle with a gradient linear brush has no impact on the CPU. I guess it might be a bug with the OnPaintBackground event or something.

No visible performance hit for anti-aliasing and embedded fonts.

So, transparent background is fine unless the label is updated very often (i.e. every 10 ms). The solution is to add a gradient backgrounds to the Label class (and also keep transparent backgrounds) and assign that to to the song position label in the main form.
(0000403)
svn   
2012-02-07 21:19   
The user admin has checked in files related to this issue (revision 295).

Comment:
MPfm 0.5.2.0
- Label: Added background gradient option to save CPU (instead of using transparent background).
- Reactivated background update library process for testing (now that the Label bug has been fixed).
- Added 1.03 to 1.04 script (will need to be modified later).

Related to issue 0000273 and issue 0000283.

Files modified:
U MPfm/branches/current/MPfm/frmMain.Designer.cs
U MPfm/branches/current/MPfm/frmMain.cs
U MPfm/branches/current/MPfm/frmMain.resx
U MPfm/branches/current/MPfm.Library/Library.cs
U MPfm/branches/current/MPfm.Library/MPfm.Library.csproj
A MPfm/branches/current/MPfm.Library/Scripts/1.03-1.04.sql
U MPfm/branches/current/MPfm.WindowsControls/Labels/Label.cs

(0000404)
ycastonguay   
2012-02-08 16:47   
There are still many things to optimize, but for now, replacing the transparent background of the often updated labels by a gradient background has reduced the CPU usage quite a bit. It is now quite acceptable.