Hello dear RAP devs,
I had a deadlock in my RAP application and I think I found the culprit. Please tell me if I'm wrong in my assessment.
The current implementation of findDisplay (as of 4.3) loops trough the displays and checks if they are disposed. The problem is, that in the findDisplay method the Device-Class-Lock is taken and in the isDisposed method, the deviceLock gets locked, which may already be locked. In this example by Device::dispose. which also now wants the Device-Class-Lock, which is already taken in findDisplay.
The deadlock was found by VisualVM. The deadlock information is below.
Best regards,
Dominik
DEADLOCK INFORMATION:
Found one Java-level deadlock:
=============================
"UIThread [17ed3d14]":
waiting to lock monitor 0x00000236031ae330 (object 0x0000000606453418, a java.lang.Class),
which is held by "UIThread [37fe6e1b]"
"UIThread [37fe6e1b]":
waiting to lock monitor 0x000002360336e970 (object 0x0000000617e3dd38, a org.eclipse.rap.rwt.internal.util.SerializableLock),
which is held by "UIThread [17ed3d14]"
Java stack information for the threads listed above:
===================================================
"UIThread [17ed3d14]":
at org.eclipse.swt.widgets.Display.deregister(Display.java:2255)
- waiting to lock <0x0000000606453418> (a java.lang.Class for org.eclipse.swt.graphics.Device)
at org.eclipse.swt.widgets.Display.destroy(Display.java:751)
at org.eclipse.swt.graphics.Device.dispose(Device.java:280)
- locked <0x0000000617e3dd38> (a org.eclipse.rap.rwt.internal.util.SerializableLock)
at com.orthagis.rcp.main.Main.start(Main.java:115)
at org.eclipse.rap.ui.internal.application.EntryPointApplicationWrapper.createUI(EntryPointApplicationWrapper.java:38)
at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:177)
at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:290)
- locked <0x0000000607d750c8> (a org.eclipse.rap.rwt.internal.lifecycle.UIThread)
at java.lang.Thread.runWith(java.base@21.0.7/Thread.java:1596)
at java.lang.Thread.run(java.base@21.0.7/Thread.java:1583)
at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:107)
"UIThread [37fe6e1b]":
at org.eclipse.swt.graphics.Device.isDisposed(Device.java:297)
- waiting to lock <0x0000000617e3dd38> (a org.eclipse.rap.rwt.internal.util.SerializableLock)
at org.eclipse.swt.widgets.Display.findDisplay(Display.java:946)
- locked <0x0000000606453418> (a java.lang.Class for org.eclipse.swt.graphics.Device)
at com.orthagis.rcp.main.RcpActionBarAdvisor.getMailActionForThread(RcpActionBarAdvisor.java:408)
at com.orthagis.rcp.editor.EntityEditorActionContributor.dispose(EntityEditorActionContributor.java:206)
at org.eclipse.ui.internal.EditorActionBars.dispose(EditorActionBars.java:156)
at org.eclipse.ui.internal.EditorManager.disposeEditorActionBars(EditorManager.java:362)
at org.eclipse.ui.internal.EditorReference.doDisposePart(EditorReference.java:327)
at org.eclipse.ui.internal.WorkbenchPartReference.dispose(WorkbenchPartReference.java:688)
at org.eclipse.ui.internal.WorkbenchPage.disposePart(WorkbenchPage.java:1719)
at org.eclipse.ui.internal.WorkbenchPage.handleDeferredEvents(WorkbenchPage.java:1424)
at org.eclipse.ui.internal.WorkbenchPage.deferUpdates(WorkbenchPage.java:1408)
at org.eclipse.ui.internal.WorkbenchPage.closeEditors(WorkbenchPage.java:1382)
at org.eclipse.ui.internal.WorkbenchPage.closeAllEditors(WorkbenchPage.java:1190)
at org.eclipse.ui.internal.WorkbenchPage.dispose(WorkbenchPage.java:1769)
at org.eclipse.ui.internal.WorkbenchWindow.closeAllPages(WorkbenchWindow.java:853)
at org.eclipse.ui.internal.WorkbenchWindow.hardClose(WorkbenchWindow.java:1779)
at org.eclipse.ui.internal.WorkbenchWindow.busyClose(WorkbenchWindow.java:726)
at org.eclipse.ui.internal.WorkbenchWindow$5.run(WorkbenchWindow.java:818)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:66)
at org.eclipse.ui.internal.WorkbenchWindow.close(WorkbenchWindow.java:816)
at org.eclipse.jface.window.WindowManager.close(WindowManager.java:110)
at org.eclipse.ui.internal.Workbench$14.run(Workbench.java:1151)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
at org.eclipse.ui.internal.Workbench.busyClose(Workbench.java:1148)
at org.eclipse.ui.internal.Workbench$21.run(Workbench.java:1337)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:66)
at org.eclipse.ui.internal.Workbench.close(Workbench.java:1335)
at org.eclipse.ui.internal.Workbench.close(Workbench.java:1297)
at org.eclipse.ui.internal.Workbench$ShutdownHandler.handleEvent(Workbench.java:387)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:109)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:664)
at org.eclipse.swt.widgets.Display.sendDisposeEvent(Display.java:755)
at org.eclipse.swt.widgets.Display.release(Display.java:738)
at org.eclipse.swt.graphics.Device.dispose(Device.java:279)
- locked <0x0000000625013178> (a org.eclipse.rap.rwt.internal.util.SerializableLock)
at com.orthagis.rcp.main.Main.start(Main.java:115)
at org.eclipse.rap.ui.internal.application.EntryPointApplicationWrapper.createUI(EntryPointApplicationWrapper.java:38)
at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle.createUI(RWTLifeCycle.java:177)
at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:290)
- locked <0x00000006250120b8> (a org.eclipse.rap.rwt.internal.lifecycle.UIThread)
at java.lang.Thread.runWith(java.base@21.0.7/Thread.java:1596)
at java.lang.Thread.run(java.base@21.0.7/Thread.java:1583)
at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:107)
_______________________________________________