Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FireMonkey Performance Issues

I am using Delphi XE2 with update 4 hotfix 1

My default FMX app is stating very slow and on event it is freezing for a while. Eg: when i click on a button, the whole application freezes for some seconds(but only for the first execution of that event). So i thought it might be a GPU problem and edited my default Dpr file as ;

uses
  FMX.Forms,  fmx.Types,..

{$R *.res}

begin
  Application.Initialize;

  GlobalUseHWEffects := False   ;
  GlobalUseDirect2D := False  ;
  GlobalUseDirect2DSoftware := False    ;
  GlobalUseGDIPlusClearType := True    ;
  GlobalDisableFocusEffect := True   ;

  Application.CreateForm(...);
  Application.Run;
end.

Now it works as i expected without any problem, but the CPU usage is as previous(25% when moving mouse)

Then i modified my code as

  GlobalUseHWEffects := true  ;
  GlobalUseDirect2D := False  ;
  GlobalUseDirect2DSoftware := False    ;
  GlobalUseGDIPlusClearType := True    ;
  GlobalDisableFocusEffect := True   ;

Now everything is working smooth , only a small delay in statup time and CPU usage is very low (0 - 2 %).(that's why i need Firemonkey)

now all the controls are working as expected except Menubar, above settings are not applied to menubar and it is working with default behavior(whole app freezes for some seconds).

What can i do to over come this problem.

like image 599
VibeeshanRC Avatar asked Jun 04 '12 07:06

VibeeshanRC


1 Answers

The real problem was with some firemonkey Effects and Firemonkeys default settings

default GlobalUseDirect2D = true while GlobalUseHWEffects := true is the real cause for performance issue, enabling both is using both CPU and GPU in my machine.So make one of them to false. I recommend you to do GlobalUseDirect2D = false and GlobalUseHWEffects := true for less usage of CPU.

And now you will be also able to get improved fonts (best ever firemonkey can generate)

Not all the customers will have high end Graphic GPUs

I am using an Intel Mobile graphic chip, so i don't think my one will have all the capabilities to support all firemonkey effects. following the code and comment can be seen in FMX.Types

// On low-end hardware or mobile bitmap effects are slowly
  GlobalDisableFocusEffect: Boolean = False;

but i can't understand why they have made it false by default.(so enable and disable depends on client GPU capabilities)

by GlobalDisableFocusEffect you will no more able to use Effects (eg: outergloweffect ).... but again this statement is still no more true....

by GlobalDisableFocusEffect not all the effects are disabled,

for example

  1. Tinnergloweffect in button style in windows style is the reason for freezing
  2. Tinnergloweffect in headeritemstyle in Dark style is the reason freezing.

and there may be tons of example...

So in my scenario i was forced to remove all effects form the style.., Blend , Dark styles are working much better because they use less TEffects (?) ,but now i am having a better GUI with better performance (I feel Blend and Dark styles look cool than native like UIs )

like image 96
VibeeshanRC Avatar answered Oct 20 '22 06:10

VibeeshanRC