Bug 188091 - [WorkbenchLauncher] org.eclipse.swt.SWTError: No more handles when RCP starts
Summary: [WorkbenchLauncher] org.eclipse.swt.SWTError: No more handles when RCP starts
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Framework (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.3.1   Edit
Assignee: equinox.framework-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
: 196411 197691 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-05-21 09:33 EDT by C. Apostolou CLA
Modified: 2007-07-24 15:38 EDT (History)
4 users (show)

See Also:
tjwatson: review+


Attachments
patch (1.81 KB, patch)
2007-07-18 17:28 EDT, Andrew Niefer CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description C. Apostolou CLA 2007-05-21 09:33:53 EDT
When I start an RCP the app fails and the following errors get written in the .log
!ENTRY org.eclipse.osgi 4 0 2007-05-21 12:20:35.531
!MESSAGE Application error
!STACK 1
org.eclipse.swt.SWTError: No more handles
 	at org.eclipse.swt.SWT.error(SWT.java:3573)
 	at org.eclipse.swt.SWT.error(SWT.java:3465)
 	at org.eclipse.swt.SWT.error(SWT.java:3436) 
and many more
I found out that if I remove the line 
Platform.endSplash();
the problem stops
Comment 1 Kim Horne CLA 2007-05-22 12:02:14 EDT
C Apostolou:  what does the rest of that stack trace look like?

Andrew, any ideas?  Has the new splash wrapper been tested on 2k?
Comment 2 Kim Horne CLA 2007-06-05 14:16:56 EDT
Without further information we cannot proceed.
Comment 3 C. Apostolou CLA 2007-06-19 00:54:03 EDT
(In reply to comment #2)
> Without further information we cannot proceed.
> 
ok here you are, sorry about the delay
and yes I work on XP

!SESSION 2007-05-23 20:45:49.328 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_01
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=el_GR
Framework arguments:  -product gr.apeirotan.planNET.product
Command-line arguments:  -product gr.apeirotan.planNET.product -data E:\workspace/../runtime-planNET -dev file:E:/workspace/.metadata/.plugins/org.eclipse.pde.core/planNET/dev.properties -os win32 -ws win32 -arch x86 -clean -debug

!ENTRY org.eclipse.osgi 4 0 2007-05-23 20:45:53.578
!MESSAGE Application error
!STACK 1
org.eclipse.swt.SWTError: No more handles
   at org.eclipse.swt.SWT.error(SWT.java:3573)
   at org.eclipse.swt.SWT.error(SWT.java:3465)
   at org.eclipse.swt.SWT.error(SWT.java:3436)
   at org.eclipse.swt.widgets.Widget.error(Widget.java:432)
   at org.eclipse.swt.widgets.Control.createHandle(Control.java:602)
   at org.eclipse.swt.widgets.Composite.createHandle(Composite.java:235)
   at org.eclipse.swt.widgets.Control.createWidget(Control.java:618)
   at org.eclipse.swt.widgets.Scrollable.createWidget(Scrollable.java:131)
   at org.eclipse.swt.widgets.Control.<init>(Control.java:97)
   at org.eclipse.swt.widgets.Scrollable.<init>(Scrollable.java:72)
   at org.eclipse.swt.widgets.Composite.<init>(Composite.java:93)
   at org.eclipse.ui.splash.BasicSplashHandler.getBundleProgressMonitor(BasicSplashHandler.java:159)
   at org.eclipse.ui.splash.BasicSplashHandler.getContent(BasicSplashHandler.java:265)
   at org.eclipse.ui.internal.splash.EclipseSplashHandler.init(EclipseSplashHandler.java:84)
   at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:595)
   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
   at org.eclipse.ui.internal.Workbench.createSplashWrapper(Workbench.java:611)
   at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2248)
   at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
   at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
   at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
   at gr.apeirotan.planNET.Application.start(Application.java:142)
   at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:153)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:497)
   at org.eclipse.equinox.launcher.Main.basicRun(Main.java:436)
   at org.eclipse.equinox.launcher.Main.run(Main.java:1162)
   at org.eclipse.equinox.launcher.Main.main(Main.java:1137)
Comment 4 Kim Horne CLA 2007-06-19 06:39:22 EDT
And you say removing Platform.endSplash makes this better?  End splash is called after the events of this trace... were you calling it yourself?
Comment 5 C. Apostolou CLA 2007-06-19 09:24:26 EDT
yes I call it my self and when I call it I get this trace.

Comment 6 Kim Horne CLA 2007-06-19 09:46:33 EDT
When do you call it?  Why are you calling it?  Is the default behavior not sufficient for your application?
Comment 7 Andrew Niefer CLA 2007-06-19 09:53:46 EDT
I suspect he is calling Platform.endSplash too early.  This ends up calling IApplicationContext.applicationRunning and tearing down the splash screen.

The Workbench is not initialized yet and continues to try and place SWT widgets in the splash which no longer exists.

DefaultStartupMonitor.applicationRunning does the actual splash tear down  If we have anything to do, it is to remove the org.eclipse.equinox.launcher.splash.handle system property when we take down the splash so that the workbench does not try to put anything in it.
Comment 8 Kim Horne CLA 2007-07-17 12:27:41 EDT
*** Bug 196411 has been marked as a duplicate of this bug. ***
Comment 9 Kim Horne CLA 2007-07-17 12:28:20 EDT
Andrew, can we look into the fix you suggested for 3.4 and maybe even 3.3.1?
Comment 10 Andrew Niefer CLA 2007-07-17 12:54:36 EDT
fix will be trivial
Comment 11 Nguy&#7877;n V&#259;n D&#361;ng CLA 2007-07-18 01:30:01 EDT
I call Platform.endSplash() on both platform Linux (glibc version 6.x) and Windows, both of them face this problem but window could not run after facing this bug. I call this function because I face problem listing bellow:
 1. Run my application.
 2. Close the splash when login dialog show.
But I could not close the splash. I solve this problem using my way, in this way I get the splash shell and set visible is false, this way run well on Linux but In window It throws StackOverflowException. I show the code to get the splash shell:

String splashHandle = System.getProperty("org.eclipse.equinox.launcher.splash.handle"); //$NON-NLS-1$
			if (splashShell == null) {
					// look for the 32 bit internal_new shell method
					try {
						Method method = Shell.class
								.getMethod(
										"internal_new", new Class[] { Display.class, int.class }); //$NON-NLS-1$
						// we're on a 32 bit platform so invoke it with splash
						// handle as an int
						splashShell = (Shell) method.invoke(null, new Object[] {
								display, new Integer(splashHandle) });
					} catch (NoSuchMethodException e) {
						// look for the 64 bit internal_new shell method
						try {
							Method method = Shell.class
									.getMethod(
											"internal_new", new Class[] { Display.class, long.class }); //$NON-NLS-1$

							// we're on a 64 bit platform so invoke it with a long
							splashShell = (Shell) method.invoke(null,
									new Object[] { display,
											new Long(splashHandle) });
						} catch (NoSuchMethodException e2) {
							// cant find either method - don't do anything.
						}
					}
					
I don't know why, please show me the way to solved this problem.
Note: This bug occur when using Windows XP.
 
Comment 12 Andrew Niefer CLA 2007-07-18 17:28:03 EDT
Created attachment 74095 [details]
patch
Comment 13 Andrew Niefer CLA 2007-07-18 17:43:29 EDT
Platform.endSplash() is the preferred way to take down the splash screen.

To work around the org.eclipse.swt.SWTError: No more handles problem, remove the splash.handle from the system properties after taking down the splash:
System.getProperties().remove("org.eclipse.equinox.launcher.splash.handle")
Which will prevent the workbench from trying to do the splash screen later.
Comment 14 Andrew Niefer CLA 2007-07-23 11:35:49 EDT
Done in HEAD and 3.3.1.  

Please open a new bug for the StackOverflowException mentioned in comment #11 and attach a stack trace.
Comment 15 Andrew Niefer CLA 2007-07-24 15:38:01 EDT
*** Bug 197691 has been marked as a duplicate of this bug. ***