Archive for August 23, 2014

RTL fixup must have for Smart Mobile Studio

August 23, 2014 3 comments

If you own Smart Mobile Studio you may want to apply this fix. Please note that I have not tested this with more than 5 different apps, but it’s a very small alteration so it poses no real threat. Just revert the few lines it entails to the official release should anything negative occur.

And remember, this is not an “official site” for the product — but rather a personal, research & development blog.

Ayways – under HTML5, scaling a control causes a massive efficiency hit. The reason for this is not just that the whole DOM has to be re-calculated, but also that the internal resize function is triggered – which (depending in the complexity of your controls and code) can be processor hungry. When I write “hungry” I am talking about milliseconds — but a drop here and there is quickly a full glass.

This small patch forces the RTL to synchronize it’s resize operations using RequestAnimationFrame – which means the browser tries to collect and redraw as many updates to the screen in one go. This results in smoother display updates and in general – a more efficient UI.



Patching up w3components

Simply open up w3components.pas and locate the method TW3CustomControl.AfterUpdate(). Remark out the code there (just for safety in case you want to go back) and replace it with the following code. You should immediately notice that things become faster and more smooth:


procedure TW3CustomControl.AfterUpdate;
  (* was a resize issued? *)
  if GetWasSized then
    if  ObjectReady
    and (Width>0)
    and (Height>0) then
      w3_RequestAnimationFrame(Procedure ()
          if Assigned(FOnResize) then

    (* do we need a re-draw? *)
    if not GetWasMoved then

  (* Only issue a redraw once *)
  if GetWasMoved then

  (* FWasMoved := False;
  FWasSized := False; *)

Another vital tip for more speed, is to use BeginUpdate and EndUpdate whenever you alter your control size and/or content. This prevents resize to be called until all adjustments have executed (this is really an important point, so keep this in mind).