MagicFoundation / Alcinoe

Alcinoe Component Library For Delphi. Full opengl video player, WebRTC delphi wrapper, native ios/android TEdit, Improuved firemonkey controls, Firebase cloud messaging, Android/ios facebook sdk login, Json/Bson Parser, ImageMagick wrapper, MongoDb client And much more
Apache License 2.0
974 stars 214 forks source link

Poor performance in mouse operations #73

Open viniciusfbb opened 5 years ago

viniciusfbb commented 5 years ago

https://github.com/Zeus64/alcinoe/blob/329361c3c51cd40f09eec1597e33780b36f94eb1/references/embarcadero/rio/10_3_1/patched/fmx/FMX.Controls.pas#L509-L513

All components are losing performance in mouse operations because of this. An easy demo would be when we click a button (keeping the mouse down) and see its animation performing poorly, especially on android phones. You wanted to pass along the mouse operations to be captured by ScrollBox, for example, even when the component inside it have HitTest True, but that way all controls lose performance.

An "ugly" but simple solution would be for the programmer to manually pass these mouse operations over to ScrollBox when needed, creating this same procedures but they will trigger just when the programmer call it, not in ever mouse operations of all controls.

(Sorry for my bad english)

Zeus64 commented 5 years ago

hmm, that strange, I didn't see any performance loss in my test. In fact, I even see a performance improvement. do you have a demo or something like this that I could test? actually, https://play.google.com/store/apps/details?id=club.kiskis.app&hl=en is made with this and there is not performance penalty but maybe your scenario is different ...

viniciusfbb commented 5 years ago

Correction: Slowness is in ChildrenMouseXXX override implemented in TALCustomScrollBox

https://github.com/Zeus64/alcinoe/blob/329361c3c51cd40f09eec1597e33780b36f94eb1/source/ALFmxLayouts.pas#L886-L928

Here is the demo: Alcinoe_Inssue_Demo.zip

viniciusfbb commented 5 years ago

I still don't fully understand it, but the issue is solved by removing this line:

https://github.com/Zeus64/alcinoe/blob/329361c3c51cd40f09eec1597e33780b36f94eb1/source/ALFmxInertialMovement.pas#L792

Zeus64 commented 5 years ago

I will take a look at it ! thanks !

viniciusfbb commented 5 years ago

Stephane, I found the real problem. It is here:

https://github.com/Zeus64/alcinoe/blob/329361c3c51cd40f09eec1597e33780b36f94eb1/references/embarcadero/rio/10_3_1/patched/fmx/FMX.Platform.UI.Android.pas#L2337-L2341

Just remove it.

Zeus64 commented 5 years ago

I ran your demo, With_Children and Without_Children and there is absolutely no difference :( what phone are you using for your test?

viniciusfbb commented 5 years ago

Android Galaxy S8+ The problem is your changes in FMX.Platform.UI.Android.pas.

When the button is pressed, you are rendering the animation only when the mouse moves, but when the mouse is stopped, the animation is not rendered.

Zeus64 commented 5 years ago

as far as I see there is no impact, did you run the app in debugging? can you try to run it in release just to see?

Zeus64 commented 4 years ago

@viniciusfbb do you still have the problem ? today i face a strange problem where everything was very slow. I uninstall the app from the mobile, delete all dcu, clean everything, and rebuild and resinstall the app and it's start again to work well and fast. I absolutely have no idea why at the beginning the app was running slow :(

viniciusfbb commented 4 years ago

@Zeus64 That was a long time ago, I don’t remember, but in my git it’s registered that the solution to this was to change the FMX.Platform.UI.Android.pas. https://github.com/viniciusfbb/alcinoe/commit/21997b61d6c43722b976b8debdadba3e0a1ba38c

I think this was the solution, but anyway it was solved at the time, I still use Alcinoe, not everything, but I use the fixes, TALTexture, TALAnimation and TALVertScrollBox, with Delphi 10.3.3, both for Android and for iOS it is working perfectly and very quickly. Much faster than native Delphi components!

viniciusfbb commented 4 years ago

@Zeus64 If you still haven't solved the problem, I found another change here at the time in ALFmxInertialMovement.pas:

procedure TALAniCalculations.TDisplayLinkListener.displayLinkUpdated;   
begin   
  if not fAniCalculations.Down then ///////// <<<<<<<<<<<
  begin 
    if assigned(fAniCalculations.fOnTimer) then 
      fAniCalculations.fOnTimer(fAniCalculations)   
    else    
      fAniCalculations.Calculate;   
  end;  
end;