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

Bug 346914

Summary: Zest incubator: NullpointerException because of missing Scrollbars on Scrollable
Product: [RT] RAP Reporter: Arnaud MERGEY <a_mergey>
Component: IncubatorAssignee: Project Inbox <rap.incubator-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: austin.riddle
Version: 1.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
To reproduce the issue, just launch snippet.zest.launch
none
patch variant1
none
patch variant2
none
ugly workaround to check zest in RAP none

Description Arnaud MERGEY CLA 2011-05-23 18:23:18 EDT
I am starting to test zest port in the incubator.
With RAP 1.4 RC2 (CVS tag) I am facing a NullPointerException, because Scrollable implementation return null for scrollbars

I have a snippet to reproduce the issue and a patch proposal

!ENTRY org.eclipse.ui.workbench 4 0 2011-05-24 00:16:52.532
!MESSAGE Unable to create view ID snippet.zest.view: An unexpected exception was thrown.
!STACK 0
java.lang.NullPointerException
	at org.eclipse.zest.core.widgets.Graph.<init>(Graph.java:134)
	at org.eclipse.zest.core.viewers.GraphViewer.<init>(GraphViewer.java:73)
	at snippet.zest.View.createPartControl(View.java:95)
	at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:375)
	at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:226)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:599)
	at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:318)
	at org.eclipse.ui.internal.ViewPane.setVisible(ViewPane.java:542)
	at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:185)
	at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:265)
	at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:64)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:479)
	at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1262)
	at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1215)
	at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1614)
	at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:659)
	at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:585)
	at org.eclipse.ui.internal.PartSashContainer.createControl(PartSashContainer.java:573)
	at org.eclipse.ui.internal.PerspectiveHelper.activate(PerspectiveHelper.java:269)
	at org.eclipse.ui.internal.Perspective.onActivate(Perspective.java:980)
	at org.eclipse.ui.internal.WorkbenchPage.onActivate(WorkbenchPage.java:2627)
	at org.eclipse.ui.internal.WorkbenchWindow$26.run(WorkbenchWindow.java:3077)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:66)
	at org.eclipse.ui.internal.WorkbenchWindow.setActivePage(WorkbenchWindow.java:3058)
	at org.eclipse.ui.internal.WorkbenchWindow.busyOpenPage(WorkbenchWindow.java:763)
	at org.eclipse.ui.internal.Workbench$19.runWithException(Workbench.java:1267)
	at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:32)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:207)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:1053)
	at org.eclipse.ui.internal.StartupThreading.runWithWorkbenchExceptions(StartupThreading.java:55)
	at org.eclipse.ui.internal.Workbench.busyOpenWorkbenchWindow(Workbench.java:1263)
	at org.eclipse.ui.internal.Workbench.doOpenFirstTimeWindow(Workbench.java:2062)
	at org.eclipse.ui.internal.Workbench.openFirstTimeWindow(Workbench.java:1993)
	at org.eclipse.ui.internal.WorkbenchConfigurer.openFirstTimeWindow(WorkbenchConfigurer.java:188)
	at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:790)
	at org.eclipse.ui.internal.Workbench$28.runWithException(Workbench.java:1641)
	at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:32)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:207)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:1053)
	at org.eclipse.ui.internal.StartupThreading.runWithoutExceptions(StartupThreading.java:110)
	at org.eclipse.ui.internal.Workbench.init(Workbench.java:1636)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2655)
	at org.eclipse.ui.internal.Workbench.access$5(Workbench.java:2530)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:702)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:685)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:157)
	at snippet.zest.Application.start(Application.java:18)
	at org.eclipse.rap.ui.internal.application.EntrypointApplicationWrapper.createUI(EntrypointApplicationWrapper.java:27)
	at org.eclipse.rwt.internal.lifecycle.EntryPointManager.createUI(EntryPointManager.java:73)
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:211)
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:88)
	at java.lang.Thread.run(Thread.java:662)
	at org.eclipse.rwt.internal.lifecycle.UIThread.run(UIThread.java:102)
Comment 1 Arnaud MERGEY CLA 2011-05-23 18:25:07 EDT
Created attachment 196381 [details]
To reproduce the issue, just launch snippet.zest.launch
Comment 2 Arnaud MERGEY CLA 2011-05-23 18:44:14 EDT
Created attachment 196384 [details]
patch variant1

Add scrollbar to avoid nullpointerException
Comment 3 Arnaud MERGEY CLA 2011-05-23 18:55:35 EDT
Created attachment 196385 [details]
patch variant2

According to code comments and some FIXME comments in ScrolledComposite,
it is probably better to instantiate scrollbar in Scrollable class
Comment 4 Arnaud MERGEY CLA 2011-05-23 18:59:20 EDT
After fixing the scrollbar issue, there is still somthing wrong with a Color widget disposed (see stack trace above)

To reproduce, launch the attached snippet, with one of the given attached patch

2011-05-24 00:56:42.687:WARN::ERROR:  /view
org.eclipse.swt.SWTException: Graphic is disposed
	at org.eclipse.swt.SWT.error(SWT.java:3538)
	at org.eclipse.swt.SWT.error(SWT.java:3458)
	at org.eclipse.swt.SWT.error(SWT.java:3429)
	at org.eclipse.swt.graphics.Color.getRed(Color.java:174)
	at org.eclipse.rwt.lifecycle.JSWriter.getColorValue(JSWriter.java:904)
	at org.eclipse.rwt.lifecycle.JSWriter.createParamList(JSWriter.java:839)
	at org.eclipse.rwt.lifecycle.JSWriter.createParamList(JSWriter.java:807)
	at org.eclipse.rwt.lifecycle.JSWriter.call(JSWriter.java:597)
	at org.eclipse.swt.internal.widgets.canvaskit.GCOperationWriter.setProperty(GCOperationWriter.java:233)
	at org.eclipse.swt.internal.widgets.canvaskit.GCOperationWriter.write(GCOperationWriter.java:72)
	at org.eclipse.swt.internal.widgets.canvaskit.CanvasLCA.writeGCOperations(CanvasLCA.java:62)
	at org.eclipse.swt.internal.widgets.canvaskit.CanvasLCA.renderChanges(CanvasLCA.java:45)
	at org.eclipse.rwt.lifecycle.AbstractWidgetLCA.render(AbstractWidgetLCA.java:36)
	at org.eclipse.swt.internal.widgets.displaykit.DisplayLCA$RenderVisitor.render(DisplayLCA.java:72)
	at org.eclipse.swt.internal.widgets.displaykit.DisplayLCA$RenderVisitor.doVisit(DisplayLCA.java:56)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor$AllWidgetTreeVisitor.visit(WidgetTreeVisitor.java:36)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:50)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
	at org.eclipse.swt.internal.widgets.WidgetTreeVisitor.accept(WidgetTreeVisitor.java:57)
	at org.eclipse.swt.internal.widgets.displaykit.DisplayLCA.renderShells(DisplayLCA.java:175)
	at org.eclipse.swt.internal.widgets.displaykit.DisplayLCA.render(DisplayLCA.java:147)
	at org.eclipse.rwt.internal.lifecycle.Render.execute(Render.java:29)
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.continueLifeCycle(RWTLifeCycle.java:190)
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.sleep(RWTLifeCycle.java:260)
	at org.eclipse.swt.widgets.Display.sleep(Display.java:1165)
	at org.eclipse.ui.application.WorkbenchAdvisor.eventLoopIdle(WorkbenchAdvisor.java:361)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2734)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2694)
	at org.eclipse.ui.internal.Workbench.access$5(Workbench.java:2530)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:702)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:685)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:157)
	at snippet.zest.Application.start(Application.java:18)
	at org.eclipse.rap.ui.internal.application.EntrypointApplicationWrapper.createUI(EntrypointApplicationWrapper.java:27)
	at org.eclipse.rwt.internal.lifecycle.EntryPointManager.createUI(EntryPointManager.java:73)
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:211)
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:88)
	at java.lang.Thread.run(Thread.java:662)
	at org.eclipse.rwt.internal.lifecycle.UIThread.run(UIThread.java:102)
Comment 5 Arnaud MERGEY CLA 2011-05-23 19:24:42 EDT
Created attachment 196387 [details]
ugly workaround to check zest in RAP

I did not manage yet to find the cause of the "color disposed" issue, so in order 
to check if zest could work in RAP, I did something ugly, (commented the dispose check in Color), just to see if zest can work in RAP

Even I am ashamed of it, I provide this ugly patch, if someone wants to see zest working in RAP :)
Comment 6 Rüdiger Herrmann CLA 2011-06-07 17:40:20 EDT
Arnaud,

the missing scroll bars are a problem in RWT. Please open a sepate bug regarding the missing scroll bars on Scrolllable.

Though I haven't been able to entirely track it down, the color-disposed-exception looks rather like a bug in Zest. Disposing of a color that is still in use is not permitted in SWT. However, the behavior differs from platform to platform. E.g. on Windows this case is motly silently ignored, whereas in RWT it inevitably leads to an exception.
Code like the one below might be silently ignored on some platforms, but throw an exception on others:
  Color color = new Color( display, 255, 255, 255 );
  widget.sertBackground( color );
  color.dispose();
Are you able to narrow the source of the problem?

HTH
Rüdiger
Comment 7 Austin Riddle CLA 2011-06-08 09:53:17 EDT
Hi Arnaud, 

I have
Comment 8 Austin Riddle CLA 2011-06-08 09:59:00 EDT
Oops. The last post was incomplete.

Hi Arnaud, 
 
I have fixed the null pointer issue by porting the Graph class to use a Slider implementation for scrollbars. IT is committed to CVS head. This had already been done for the GEF port, but Zest was overlooked.  Sorry for the confusion.

The Zest issue about the disposed colors I have seen as well. But I can seem to work around it in most cases by avoiding certain Graph connection types.

Hope this helps. Please re-open if you experience the null pointer again.
Thanks.
Comment 9 Arnaud MERGEY CLA 2011-06-09 09:48:27 EDT
Thanks for the fix, the NullpointerException is gone now.

Could you provide more information about how you workaround the disposed color issue ? what do you mean by avoiding certain graph connection types ? Sorry, I am quite new to Zest.

Thanks again.
Comment 10 Rüdiger Herrmann CLA 2011-07-05 14:12:45 EDT
The actual problem seems to be in RWT (see bug bug 351216).