Page 1 of 5

issue-#105 background task processing while mouse tracking

Posted: Fri Feb 19, 2016 1:54 pm
by Josef Templ
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/pr ... 115335d51f.

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

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

Posted: Sat Feb 20, 2016 2:39 am
by Ivan Denisov
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.

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

Posted: Sat Feb 20, 2016 7:10 am
by luowy
HostWindows.Idle

Code: Select all

	
		...      
		Services.actionHook.Step;
		Windows.dir.Update(NIL);(*20080122*)
	END Idle;

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

Posted: Sat Feb 20, 2016 7:48 am
by Josef Templ
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

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

Posted: Sat Feb 20, 2016 9:01 am
by Ivan Denisov
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.

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

Posted: Sat Feb 20, 2016 9:04 am
by Ivan Denisov
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 ?

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

Posted: Sat Feb 20, 2016 10:07 am
by luowy
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;

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

Posted: Sat Feb 20, 2016 4:58 pm
by Ivan Denisov
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.

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

Posted: Mon Feb 22, 2016 8:04 am
by Josef Templ
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

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

Posted: Mon Feb 22, 2016 8:07 am
by Josef Templ
- 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