Bug 573497 - SWT "no more handles" when using the color palette too much
Summary: SWT "no more handles" when using the color palette too much
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 6.4.2   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: 7.0.0   Edit
Assignee: Laurent Redor CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks: 574456 574457
  Show dependency tree
 
Reported: 2021-05-12 04:43 EDT by William Piers CLA
Modified: 2022-02-28 04:22 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description William Piers CLA 2021-05-12 04:43:49 EDT
Steps to reproduce:
* install the starter example
* select any element
* in the appearance tab, click on the "paint bucket" icon. Like, many many times, for 10s or more
* eclipse shuts down, the error log shows:

org.eclipse.swt.SWTError: No more handles
	at org.eclipse.swt.SWT.error(SWT.java:4749)
	at org.eclipse.swt.SWT.error(SWT.java:4638)
	at org.eclipse.swt.SWT.error(SWT.java:4609)
	at org.eclipse.swt.widgets.Display.error(Display.java:1240)
	at org.eclipse.swt.widgets.Display.internal_new_GC(Display.java:2650)
	at org.eclipse.swt.graphics.Image.getImageDataAtCurrentZoom(Image.java:1547)
	at org.eclipse.swt.graphics.Image.getImageData(Image.java:1370)
	at org.eclipse.swt.internal.ImageList.set(ImageList.java:365)
	at org.eclipse.swt.internal.ImageList.add(ImageList.java:52)
	at org.eclipse.swt.widgets.Button._setImage(Button.java:131)
	at org.eclipse.swt.widgets.Button.setImage(Button.java:891)
	at org.eclipse.sirius.diagram.ui.tools.internal.dialogs.ColorPalettePopup.<init>(ColorPalettePopup.java:185)
	at org.eclipse.sirius.diagram.ui.tools.internal.properties.DiagramShapeColorAndFontPropertySection.changeColor(DiagramShapeColorAndFontPropertySection.java:136)
	at org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ColorsAndFontsPropertySection.changeColor(ColorsAndFontsPropertySection.java:372)
	at org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ShapeColorsAndFontsPropertySection.changeFillColor(ShapeColorsAndFontsPropertySection.java:85)
	at org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ShapeColorsAndFontsPropertySection$1.widgetSelected(ShapeColorsAndFontsPropertySection.java:42)

Obviously the use case I mention does not happen regularly, but if an user uses the palette regularly for several hours he will encounter it (that's how the bug was found).
Comment 1 Glenn Plouhinec CLA 2021-05-12 05:31:41 EDT
I was able to reproduce the issue on ODCE 11.4 and 11.5 with an ecore diagram, we should be able to reproduce it on any element of any diagram.
Comment 2 Glenn Plouhinec CLA 2021-05-12 13:54:20 EDT
Note that it may be useful to display the Properties view and the Error Log in parallel beforehand. The error can be opened when restarting Eclipse, since it does not respond at all when reproducing the issue.
Comment 3 Laurent Redor CLA 2021-05-17 07:49:44 EDT
There are 2 different issues linked to the ColorPalettePopup:
* a leak on Image and/or Button (that can result in "SWTError: No more handles")
* a global leak on the ColorPalettePopup and the associated Shell, that are not disposed in some circumstances (exit of the popup without clicking on any button).
Comment 4 Eclipse Genie CLA 2021-05-17 07:51:32 EDT
New Gerrit change created: https://git.eclipse.org/r/c/sirius/org.eclipse.sirius/+/180674
Comment 5 Eclipse Genie CLA 2021-05-17 07:51:34 EDT
New Gerrit change created: https://git.eclipse.org/r/c/sirius/org.eclipse.sirius/+/180675
Comment 6 Laurent Redor CLA 2021-05-17 08:00:26 EDT
There are two ways to validate:

FIRST WAY: Steps to validate with debug mode
* Open a diagram with at least a node (or a container)
* Select a node (or a container)
* Open the Properties view and select the tab "Appearance"
* Click 10 times on the "paint bucket" button (button to change the background color of the node)
* Add a breakpoint on l.141 in method org.eclipse.sirius.diagram.ui.tools.internal.properties.DiagramShapeColorAndFontPropertySection.changeColor(SelectionEvent, Button, String, String, ImageDescriptor), just before opening the ColorPalettePopup ("popup.open(...)").
* Click on the "paint bucket" button
* Expected: The code stops on the breakpoint.
* In the Debug Shell view, write this code and execute it:

    System.out.println("======================");
    System.out.println("Nb shells = " + 
    button.getParent().getShell().getShells().length);
    for (org.eclipse.swt.widgets.Shell aShell : button.getParent().getShell().getShells()) {
        System.out.println("* Is disposed : " + aShell.isDisposed());
    }
    System.out.println("======================");

* The result is displayed in the Console view.
* Expected: With the fix, the number of shells should be around 6 (none are disposed). Without the fix, the number of shells is around 16 (none are disposed).
* Disable the breakpoint
* Resume the code execution
* Click again 10 times on the "paint bucket" button
* Activate the breakpoint
* Click on the "paint bucket" button
* Expected: The code stops on the breakpoint.
* In the Debug Shell view, execute the code.
* Expected: With the fix, the number of shells is the same than the first time. Without the fix, the number of shells is 11 more.

SECOND WAY: Steps to validate with Yourkit
* Launch Sirius with Yourkit
* Open a diagram with at least a node (or a container)
* Display the "heap status" (menu Window/Preferences > General/Show heap status)
* Select a node (or a container)
* Open the Properties view and select the tab "Appearance"
* Click 10 times on the "paint bucket" button (button to change the background color of the node)
* Run Garbage Collector (by using corresponding button near the heap status)
* Capture a Memory Snapshot
* In Yourkit, in the Class section, filter on "org.eclipse.sirius.diagram.ui.tools.internal.dialogs.ColorPalettePopup"
* Expected: No such object exists. Without the fix, the number of objects is 10.
* In Yourkit, in the Class section, filter on "org.eclipse.swt.graphics.RGB"
* Expected: A lot of RGB is count. Note the number.
* In Yourkit, in the Class section, filter on "org.eclipse.swt.graphics.Image"
* Expected: A lot of Image is count. Note the number.
* In Yourkit, in the Class section, filter on "org.eclipse.swt.widgets.Button"
* Expected: A lot of Button is count. Note the number.
* Click 10 times on the "paint bucket" button (button to change the background color of the node)
* Run Garbage Collector
* Capture a Memory Snapshot
* In Yourkit, in the Class section, filter on "org.eclipse.sirius.diagram.ui.tools.internal.dialogs.ColorPalettePopup"
* Expected: No such object exists. Without the fix, the number of objects is 20.
* In Yourkit, in the Class section, filter on "org.eclipse.swt.graphics.RGB"
* Expected: The number of RGB should be the same than previous. Without the fix, the number is also the same (there is no leak on RGB).
* In Yourkit, in the Class section, filter on "org.eclipse.swt.graphics.Image"
* Expected: The number of Image should be the same than previous. Without the fix, the number is increased by 260 (26 new Image by click)
* In Yourkit, in the Class section, filter on "org.eclipse.swt.widgets.Button"
* Expected: The number of Button should be the same than previous. Without the fix, the number is increased by 270 (27 new Button by click: 26 for the Color Image button and 1 for the "Custom..." button)
Comment 9 Steve Monnier CLA 2022-02-01 20:41:02 EST
Validated with Sirius 7.0.0.202201120736. I followed the first scenario.
Comment 10 Pierre-Charles David CLA 2022-02-28 04:22:32 EST
Available in Sirius 7.0.0, see https://projects.eclipse.org/projects/modeling.sirius/releases/7.0.0