UI and whole app much slower and laggy on OSX than on Windows (BGRAControls) lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- tom.tom · 2015-01-29 16:16 Hi,   Our app uses BGRAControls quite extensively and what I noticed is that the app's UI is very laggy on OSX. Also the CPU usage jumps even up to 70% when I simply move the mouse over the UI componens forcing them to repaint. On windows whn I do the same there is maybe 1-2% increase in the CPU usage. Does anybode have any experience with that or suggestions where to look before I start debugging everything? Of course the app is compiled without debug information and stripped out, because without that it's even much worse... Thanks, Tomasz ---------------------------------------------------------------------- skalogryz · 2015-01-29 16:34 Sounds like the repainting is occurring too many times - or even worse - painting outside of the OnPaint  event. for Carbon it would forcefully trigger another paint event. ---------------------------------------------------------------------- zeljko · 2015-01-29 17:32 Or too much Repaint() instead of Update() ---------------------------------------------------------------------- tom.tom · 2015-01-30 14:36 Well, does that mean that there is some refresh/repaint chain in carbon which does not exist on windows and therefore such difference in performance? When I do the mouse over, the panel changes it's color, so yes, there is repaint triggerred, but that just a small 20px x 20px square for repainting... or does this force everything (i.e whole form) to be repainted? Tomasz ---------------------------------------------------------------------- skalogryz · 2015-01-30 15:33 Quote from: tom.tom on January 30, 2015, 03:36:50 pmWhen I do the mouse over, the panel changes it's color, so yes, there is repaint triggerred, but that just a small 20px x 20px square for repainting... or does this force everything (i.e whole form) to be repainted? Are you saying that the panel that changes the color is only 20px x 20px? Also, how do you "change" the color? are you triggering "invalidate" A) or just paint B)? A) Code: [Select]procedure TMyPanel.OnMouseMove() begin   self.invalidate; end; B) Code: [Select]procedure TMyPanel.OnMouseMove() begin   Canvas.FillColor (randomcolor, BoundsRect); end; ---------------------------------------------------------------------- tom.tom · 2015-01-30 16:04 Hmmm, this is BGRAControls - let me have a look into the code... in OnMouseEnter I do: Code: [Select]TBCPanel(TControl(Sender).Parent).Background.Color := ..... Which, looking into BGRAControls: Code: [Select]TBCBackground.SetColor ... Change; then... Code: [Select]procedure TBCProperty.Change(AData: PtrInt); begin   if Assigned(FOnChange) then     FOnChange(Self,AData); end ...so nothing really special. To be precise, there are 7 such panels and they are 52x52 size. When I move the mouse over one of them the other one that was activated before gets deactivated (changes the background back to normal color) and the new panel get's activated (backgound changes). I observe that high CPU usage when I simply move the mouse along all 7 panels back ang forth. EDIT: Have just talked to Dibo, who is one of the BGRAControls developers and he said there may be something wrong with how the underlaying BGRABitmap is supported on OSX... ---------------------------------------------------------------------- tom.tom · 2015-02-02 14:03 OK, I think I have something When in TBCPanel you set XRounding and YRouning to 0 - changing the background color takes so much time. If you do not set them to 0, there is no way to get rid of the left and top border. Will continue my research. ---------------------------------------------------------------------- tom.tom · 2015-02-02 17:36 OK, seems like there are several issues with both TBCPanel and TBGRABitmap: 1) TBCPanel seems to have Allign not working right - if I put one TBCPanel on another TBCPanel and set alTop for the inner one - there is no way to make the inner Top and Left equal to 0 - they are always at least =1 [issue #1] - event if Bevel is set to none in the parent panel 2) because of the above, setting RoundingX and RoundingY of the inner panel to 0 is a kind of hack that eliminates the visual effects of the above Allign issue, but ---> 3) 3) when setting Rounding to 0 calls FBGRA.Draw() with the Opaque param set to false -- why? what for? [issue #2] ...it seems more logical to draw the control as transparent, when rounding <>0, not opaque...? Code: [Select]procedure TCustomBCPanel.DrawControl; begin   inherited DrawControl;   if FBGRA.NeedRender then     Render;   if Assigned (FRounding) then   begin     if (FRounding.RoundX<>0) and (FRounding.RoundY<>0) then       FBGRA.Draw(Self.Canvas, 0, 0, False)     else       FBGRA.Draw(Self.Canvas, 0, 0);   end   else     FBGRA.Draw(Self.Canvas, 0, 0); end;  4) this leads to the performance problem on OSX - apparently procedure TBGRADefaultBitmap.DataDrawOpaque() on OSX is very slow [issue #3] - do not know why yet... Code: [Select]procedure TBGRADefaultBitmap.Draw(ACanvas: TCanvas; x, y: integer; Opaque: boolean); begin   if self = nil then     exit;   if Opaque then     DataDrawOpaque(ACanvas, Rect(X, Y, X + Width, Y + Height), Data,       FLineOrder, FWidth, FHeight)   else   begin     LoadFromBitmapIfNeeded;     if Empty then       exit;     ACanvas.Draw(X, Y, Bitmap);   end; end;  Any suggestions?