Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Riena » Riena 5.0.0: No More Handles
Riena 5.0.0: No More Handles [message #1269885] Wed, 12 March 2014 09:31 Go to next message
Frank Herberts is currently offline Frank Herberts
Messages: 5
Registered: March 2013
Junior Member
We are experiencing the "No more handles" problem in an SWT Riena application. This is not due to not disposing used Fonts/Colors/Images/etc. (I already tracked resource allocation with Sleak).

The problem could be that Riena seems to instantiate every view and keeps it in memory during the application up time (is that so?). We have some fairly complex masks, and each Composite seems to eat up to 4 handles (after accessing a view, the task-manager shows around 400 more user objects/handles). So after accessing around 2/3 of all views in the application, we run out of handles.

We are using shared views. Is there any way to tell Riena to dispose each view after showing? I know that this will propably result in slower GUI response time, but otherwise our application keeps crashing.

Kind regards,
Frank
Re: Riena 5.0.0: No More Handles [message #1269955 is a reply to message #1269885] Wed, 12 March 2014 10:53 Go to previous messageGo to next message
Jordan Dukadinov is currently offline Jordan Dukadinov
Messages: 15
Registered: July 2009
Location: Germany
Junior Member
Hi Frank,

Are you using Riena on Eclipse 3.x or 4.x (have a look at the version of "org.eclipse.rcp" in your target platform)?

The view parts are handled differently in both Eclipse streams. Riena is relying on RCP for their management (we only hold view id's).

We also noticed that the view parts are accumulating, and implemented a configuration for Riena, which limits the number of open views. However this feature is not contained in the Riena 5.0.0.0 since we implemented it after the release. Do you need a Riena 6 milestone before the Release in June?
Re: Riena 5.0.0: No More Handles [message #1270062 is a reply to message #1269955] Wed, 12 March 2014 13:02 Go to previous messageGo to next message
Frank Herberts is currently offline Frank Herberts
Messages: 5
Registered: March 2013
Junior Member
Hi,

we are using Riena 5.0 on E4. The problem is: we need a solution now Wink
Is it possible to close views programatically in Riena 5.0, so that (when you navigate to the same view again) it is automatically created anew?

Or is Riena 6.0 so far into development that we could get a stable build and use it now?

Kind regards,
Frank
Re: Riena 5.0.0: No More Handles [message #1270802 is a reply to message #1270062] Thu, 13 March 2014 14:13 Go to previous messageGo to next message
Jordan Dukadinov is currently offline Jordan Dukadinov
Messages: 15
Registered: July 2009
Location: Germany
Junior Member
Hi Frank,

I looked at Riena for Eclipse 4.x and there's still a problem with the view cleanup, so it is not working. I created Bug 430168 for that and we will address it in the near future.

Until the bug is fixed, you can try to work around it:

When a view has to be shown, Riena looks for it in the E4 application model. If the view is not found there, Riena looks up the contribution from the extension registry (plugin.xml) and instantiates the view part. This happens in:
org.eclipse.riena.e4.launcher.part.RienaPartHelper.createPart(ISubModuleNode)


To "clean up" views manually, you can try these steps:
(1) remove the MPart instance from the E4 application model like in
org.eclipse.riena.e4.launcher.part.RienaPartHelper.unregisterPart(MPart)

(2) remove the mapping from the ISubModuleNode to the partId by calling
subModuleNode.removeContext(RienaPartHelper.KEY_E4_PART_ID)

The next time Riena looks up this view, it should go through the process described above as if this view has never been open. Be very careful with shared views, they're also registered in the ViewInstanceProvider!

For this to work, the RCP view contributions should be in the plugin.xml (the good old Eclipse 3.x way), not in the E4 e4xmi file. In any case, the RienaPartHelper is your friend (bundle org.eclipse.riena.e4.launcher).

I hope this helps!

Cheers,
Jordan
Re: Riena 5.0.0: No More Handles [message #1271079 is a reply to message #1270802] Fri, 14 March 2014 07:36 Go to previous messageGo to next message
Frank Herberts is currently offline Frank Herberts
Messages: 5
Registered: March 2013
Junior Member
Hi Jordan,

thank you very much for your answer. I will try that today.

My next question is, how I get E4 to inject the EModelService (I guess I need it to get the MPart for the call to unregisterPart()). Can I simply use the @Inject annotation, for example, in my SubModuleController? (I never used the @Inject annotation in our RCP application...)

Kind regards,
Frank
Re: Riena 5.0.0: No More Handles [message #1271181 is a reply to message #1271079] Fri, 14 March 2014 12:50 Go to previous messageGo to next message
Frank Herberts is currently offline Frank Herberts
Messages: 5
Registered: March 2013
Junior Member
I tried this:

SubModuleNodeListener:

public void afterDeactivated() {
  // eclipseContext is retrieved in Activator
  // -> eclipseContext = EclipseContextFactory.getServiceContext(bundleContext);

  ContextHelper helper = ContextInjectionFactory.make(ContextHelper.class, 
                             eclipseContext);
  helper.disposeView(getNavigationNode());
}


and

public class ContextHelper {
	@Inject
	public static IEclipseContext context;

	@Inject
	private static EPartService partService;
	
	public void disposeView(ISubModuleNode node) {
		MPart part = findPart(node);
		if(part != null) {
			part.setWidget(null);
			part.getParent().getChildren().remove(part);
			node.removeContext("E4PartId");
		}
	}
	
	private MPart findPart(final ISubModuleNode node) {
		final String KEY_E4_PART_ID = "E4PartId"; //$NON-NLS-1$
		final String partId = (String) node.getContext(KEY_E4_PART_ID);
		if (null == partId) {
			return null;
		}
		return partService.findPart(partId);
	}

}


But I get an exception that EPartService is not contained in the IEclipseContext at that time ("that time" being the afterDeactivated() callback of a SubModuleNodeListener). An neither is EModelService (which is used in RienaPartHelper).

So I guess I did something wrong when creating my ContextHelper class.

14.03.2014 13:55:16,426 ERROR PmzRunnableProgress:159 - Callback fehlgeschlagen!:
org.eclipse.e4.core.di.InjectionException: Unable to process "ContextHelper.partService": no actual value was found for the argument "EPartService".
	at org.eclipse.e4.core.internal.di.InjectorImpl.reportUnresolvedArgument(InjectorImpl.java:412)
	at org.eclipse.e4.core.internal.di.InjectorImpl.resolveRequestorArgs(InjectorImpl.java:403)
	at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:108)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:333)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:254)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
	at pmz.ui.controller.PmzSubModuleController.afterDeactivated(PmzSubModuleController.java:175)


Kind regards,
Frank

[Updated on: Fri, 14 March 2014 12:56]

Report message to a moderator

Re: Riena 5.0.0: No More Handles [message #1272297 is a reply to message #1271181] Mon, 17 March 2014 15:19 Go to previous message
Jordan Dukadinov is currently offline Jordan Dukadinov
Messages: 15
Registered: July 2009
Location: Germany
Junior Member
Try to find the MPart as in RienaPartHelper

@Inject
private EModelService modelService;

private MPart findPart(final ISubModuleNode node) {
	final String partId = (String) node.getContext(KEY_E4_PART_ID);
	if (null == partId) {
		return null;
	}
	final List<MPart> parts = modelService.findElements(context.get(MApplication.class), partId, MPart.class, null, EModelService.IN_ANY_PERSPECTIVE);
	return parts.get(0);
}


The reason that you don't get the EPartService injected is that the E4 contexts are organized in a tree structure. The default injector look up strategy traverses from your eclipseContext to the tree root until it finds an appropriate instance to inject (in this case the EPartService). If the EPartService is available in another "branch" in the context tree, it won't be found.

Our way to look up the "right" context is this method, found in bundle org.eclipse.riena.ui.swt.e4, class WorkbenchFacadeImpl:

private IEclipseContext getWorkbenchContext() {
	final org.eclipse.e4.ui.internal.workbench.Activator plugin = org.eclipse.e4.ui.internal.workbench.Activator.getDefault();
	if (plugin == null) {
		return null;
	}
	final IEclipseContext serviceContext = EclipseContextFactory.getServiceContext(plugin.getContext());
	return serviceContext.getActiveLeaf();
}


I can't guarantee that this is the absolute correct way, but it works for us Smile
Previous Topic:Riena Snippets 5.0.0
Goto Forum:
  


Current Time: Sun Sep 21 12:16:01 GMT 2014

Powered by FUDForum. Page generated in 0.02014 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software