issue-#105 background task processing while mouse tracking

Merged to the master branch
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

issue-#105 background task processing while mouse tracking

Post 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
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

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

Post 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.
luowy
Posts: 234
Joined: Mon Oct 20, 2014 12:52 pm

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

Post by luowy »

HostWindows.Idle

Code: Select all

	
		...      
		Services.actionHook.Step;
		Windows.dir.Update(NIL);(*20080122*)
	END Idle;
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

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

Post 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
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

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

Post 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.
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

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

Post 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 ?
luowy
Posts: 234
Joined: Mon Oct 20, 2014 12:52 pm

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

Post 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;
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

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

Post 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.
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

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

Post 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
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

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

Post 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
Post Reply