Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 455504

Summary: [Contributions] [EditorMgmt] HandlerProxy.setEnabled called too much often in Luna
Product: [Eclipse Project] Platform Reporter: Tobias Melcher <tobias.melcher>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: 4.4.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug

Description Tobias Melcher CLA 2014-12-17 10:50:36 EST
Hi colleagues,

I detected that HandlerProxy#setEnabled is called too many times when an editor is closed.
In our application HandlerProxy#setEnabled is called 29036 times on 16 different HandlerProxy instances in the editor close scenario. This is simply too much and slows down performance. I would have expected that HandlerProxy#setEnabled is called exactly once on each instance ==> 16 times.


I think the problem is inside ToolbarManagerRenderer which triggers the call getUpdater().updateContributionItems(...) again and again. 

Could this be improved? An option would be to collect all updateContributionItems requests and trigger it then only once with a small delay.

Something like this:
Runnable updateContributorItemsRunnable=new Runnable() {
		
		@Override
		public void run() {
			getUpdater().updateContributionItems(ALL_SELECTOR);			
		}
	};


void updateRequest(@UIEventTopic(UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC) Event eventData) {
	Display.getDefault().timerExec(200,updateContributorItemsRunnable);
}


I tried to reproduce the problem in the current Mars dev build and it seems that it was slightly improved; now HandlerProxy#setEnabled is called 3 or 4 times on each instance. 

What do you think? Does it still make sense to introduce the timerExec call to gain performance?

With best regards,
Tobias
Comment 1 Paul Webster CLA 2014-12-22 08:30:21 EST
If it's down to 3 or 4 times per instance that's much better than it was.  I wouldn't introduce a timerExec as 1) that chews up system resources depending on your platform and 2) that makes updating the tool items unpredictable instead of synchronous, and those slight delays are noticeable to the human eye.

But I'm open to other suggestions for improvements.

PW
Comment 2 Tobias Melcher CLA 2014-12-29 09:04:29 EST
Thanks for the reply.

Sorry, I don't have other suggestions. 
Any chance to get the improvements also into the next luna release?
Comment 3 Lars Vogel CLA 2019-11-27 07:01:56 EST
This bug hasn't had any activity in quite some time. Maybe the problem got
resolved, was a duplicate of something else, or became less pressing for some
reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it.
The information can be, for example, that the problem still occurs, that you
still want the feature, that more information is needed, or that the bug is
(for whatever reason) no longer relevant.

If the bug is still relevant, please remove the stalebug whiteboard tag.