issue-#105 background task processing while mouse tracking

Merged to the master branch

issue-#105 background task processing while mouse tracking

Postby Josef Templ » Fri Feb 19, 2016 1:54 pm

This issue (http://redmine.blackboxframework.org/issues/105) is about improving
the responsiveness of BlackBox when used as a server.
It is proposed that background tasks are called even while tracking the mouse.
Technically, this is simple because all mouse tracking loops eventually call HostPorts.Rider.Input
where the background tasks can be activated.
here are the changes: http://redmine.blackboxframework.org/projects/blackbox/repository/diff?utf8=%E2%9C%93&rev=f4feca574fd59ebca326fef9ddda1e74a4a66de1&rev_to=25ec149bc41ba7c85f28a23ca25127115335d51f.

HOWEVER, this issue seems to have a long history.
There is a change line entry in HostPorts (BB1.6!) right at the beginning of the changes list:
- 20060325, mc, Rider.Input changed for the benefit of background task response.
(mc is Marco Ciot, I guess.)
This line says that the change has been done in 2006.
Since it is not in BB 1.6 it must have been removed later.
The import list still contains 'Services' which also indicates that background task execution
has been available once but removed later.
Why has it been removed?

There is another related change comment line in CPC 1.7 HostPorts. This line
is about the reinvention of this feature.
- 20080524, Alexander Iljin, Rider.Input updated to allow Services.Actions call it.

@Helmut: do you know any details about this issue and its history?

Does anybody know mc? Can we contact him?

When I saw this issue the first time I thought, wow, this is a dangerous feature.
A background task could in some way have side effects that interacts with the mouse tracking loop.
However, in practice it seems to work well. There may be exceptions, though, and may be these were the
reason for removing this feature again.

- Josef
User avatar
Josef Templ
 
Posts: 2041
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#105 background task processing while mouse tracki

Postby Ivan Denisov » Sat Feb 20, 2016 2:39 am

I found that this code not solving the problem with ObxCube... If you open the ObxCube and then try to drag and drop some text anyway the cube will freeze.
Ivan Denisov
 
Posts: 1698
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#105 background task processing while mouse tracki

Postby luowy » Sat Feb 20, 2016 7:10 am

HostWindows.Idle
Code: Select all
   
      ...     
      Services.actionHook.Step;
      Windows.dir.Update(NIL);(*20080122*)
   END Idle;
luowy
 
Posts: 233
Joined: Mon Oct 20, 2014 12:52 pm

Re: issue-#105 background task processing while mouse tracki

Postby Josef Templ » Sat Feb 20, 2016 7:48 am

Ivan Denisov wrote:I found that this code not solving the problem with ObxCube... If you open the ObxCube and then try to drag and drop some text anyway the cube will freeze.


The action is called but the Restore is delayed.

- Josef
User avatar
Josef Templ
 
Posts: 2041
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#105 background task processing while mouse tracki

Postby Ivan Denisov » Sat Feb 20, 2016 9:01 am

So the problem is not with Input procedure.

I found the analogy with regular and realtime linux kernels. The realtime kernel gives priority to input handling. The regular kernel is balanced to handle idle tasks. Now the Input is demonstrating realtime kernel behavior. However the software engineer can easily balance it. I will demonstrate this bellow.

Usually Input is used in the case of:
Code: Select all
REPEAT
    f.Input(x, y, modifiers, isDown)
    ...
UNTIL ~ isDown;


If the developer want to handle idle tasks.
Code: Select all
REPEAT
    f.Input(x,y,modifiers, isDown)
    ...
    Services.actionHook.Step;
UNTIL ~ isDown;


Or there is can be balancing using probabilistic model.
Code: Select all
REPEAT
    f.Input(x,y,modifiers, isDown)
    ...
    IF ObxRandom.Uniform() > 0.8 THEN
       Services.actionHook.Step;
   END
UNTIL ~ isDown;


So I think is good to keep this freedom. However we need to concentrate attention on the places where the framework is not optimized. Like in the example with text drag and drop.
Ivan Denisov
 
Posts: 1698
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#105 background task processing while mouse tracki

Postby Ivan Denisov » Sat Feb 20, 2016 9:04 am

luowy wrote:HostWindows.Idle
Code: Select all
   
      ...     
      Services.actionHook.Step;
      Windows.dir.Update(NIL);(*20080122*)
   END Idle;

Thanks Luowy! The only question is that this procedure is called Idle... maybe it should be idled ?
Ivan Denisov
 
Posts: 1698
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#105 background task processing while mouse tracki

Postby luowy » Sat Feb 20, 2016 10:07 am

Ivan Denisov wrote:.. maybe it should be idled ?

I not noticed it,maybe. it copyed from my own version,which some name were changed slightly.

about HostPorts.Input:
the Sleep(1) procedure should move to the end of the Inupt instead of the beginning.to avoid the delay of responding. can be understand when you moving a selected control on a form window.
Code: Select all
   
      ...
      
      WinApi.Sleep(1);
   END Input;
luowy
 
Posts: 233
Joined: Mon Oct 20, 2014 12:52 pm

Re: issue-#105 background task processing while mouse tracki

Postby Ivan Denisov » Sat Feb 20, 2016 4:58 pm

luowy wrote:
Ivan Denisov wrote:.. maybe it should be idled ?

I not noticed it,maybe. it copyed from my own version,which some name were changed slightly.

I mean that it's name is talking about the expected realization...
to idle — "(of an engine) run slowly while disconnected from a load or out of gear"
so I think that maybe Idle realization does not expected heavy calculation as Windows.dir.Update(NIL);
It is only my guess. I am just thinking aloud.
Ivan Denisov
 
Posts: 1698
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#105 background task processing while mouse tracki

Postby Josef Templ » Mon Feb 22, 2016 8:04 am

luowy wrote:
Ivan Denisov wrote:.. maybe it should be idled ?

I not noticed it,maybe. it copyed from my own version,which some name were changed slightly.

about HostPorts.Input:
the Sleep(1) procedure should move to the end of the Inupt instead of the beginning.to avoid the delay of responding. can be understand when you moving a selected control on a form window.
Code: Select all
   
      ...
      
      WinApi.Sleep(1);
   END Input;


I cannot see any delay when moving a control on a form.
The sleep is very short and it would be surprising if it can be observed
no matter if it is at the top or at the bottom.
In addition, handling the input is after Input and not within Input, as far as I see.

- Josef
User avatar
Josef Templ
 
Posts: 2041
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#105 background task processing while mouse tracki

Postby Josef Templ » Mon Feb 22, 2016 8:07 am

- 20060325, mc, Rider.Input changed for the benefit of background task response.


We must find out why the change has been removed.
Otherwise we may reintroduce a bug.

Who is mc?
Can we contact him?

- Josef
User avatar
Josef Templ
 
Posts: 2041
Joined: Tue Sep 17, 2013 6:50 am

Next

Return to Resolved (Features)

Who is online

Users browsing this forum: No registered users and 1 guest

cron