Menu

To Freeze or not to Freeze

I have recently migrated to Eclipse Mars, and it provides an interesting tool that tracks all UI freezes.

Definitely there are a lot of UI freezes, it explains why Eclipse can be sometimes so slow ! By clicking on details we can see that the UI thread is often busy due to filtering into JFace widgets, because it calls a lot of code without worrying about who is the running thread. These hooks from UI thread shall be managed with care ! Any piece of code run by UI thread shall not last more than 500ms (even less).
Below one of the stack trace of the main thread (UI thread into Equinox world)

Java

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

java.lang.Exception:Stack Trace

at org.eclipse.core.internal.watson.ElementTree.includes(ElementTree.java:527)

at org.eclipse.core.internal.resources.Workspace.getResourceInfo(Workspace.java:1698)

at org.eclipse.core.internal.resources.Resource.getResourceInfo(Resource.java:1201)

at org.eclipse.core.internal.resources.Project.internalGetDescription(Project.java:760)

at org.eclipse.core.internal.resources.Project.hasNature(Project.java:524)

at org.eclipse.jdt.internal.core.JavaProject.hasJavaNature(JavaProject.java:354)

at org.eclipse.jdt.internal.core.JavaProject.getEclipsePreferences(JavaProject.java:1484)

at org.eclipse.jdt.internal.core.JavaProject.getOption(JavaProject.java:1657)

at org.eclipse.jdt.internal.core.JavaModelManager.determineIfOnClasspath(JavaModelManager.java:1041)

at org.eclipse.jdt.internal.core.JavaModelManager.create(JavaModelManager.java:934)

at org.eclipse.jdt.internal.core.JavaModelManager.create(JavaModelManager.java:864)

at org.eclipse.jdt.core.JavaCore.create(JavaCore.java:3177)

at org.eclipse.jdt.internal.ui.JavaElementContainmentAdapter.contains(JavaElementContainmentAdapter.java:43)

at org.eclipse.ui.ResourceWorkingSetFilter.isEnclosed(ResourceWorkingSetFilter.java:102)

at org.eclipse.ui.ResourceWorkingSetFilter.select(ResourceWorkingSetFilter.java:68)

at org.eclipse.jface.viewers.ViewerFilter.filter(ViewerFilter.java:56)

at org.eclipse.ui.ResourceWorkingSetFilter.filter(ResourceWorkingSetFilter.java:168)

at org.eclipse.jface.viewers.StructuredViewer.getFilteredChildren(StructuredViewer.java:910)

at org.eclipse.jface.viewers.AbstractTreeViewer.getSortedChildren(AbstractTreeViewer.java:617)

at org.eclipse.jface.viewers.AbstractTreeViewer.updateChildren(AbstractTreeViewer.java:2645)

at org.eclipse.jface.viewers.AbstractTreeViewer.internalRefreshStruct(AbstractTreeViewer.java:1916)

at org.eclipse.jface.viewers.TreeViewer.internalRefreshStruct(TreeViewer.java:684)

at org.eclipse.jface.viewers.AbstractTreeViewer.internalRefreshStruct(AbstractTreeViewer.java:1923)

at org.eclipse.jface.viewers.TreeViewer.internalRefreshStruct(TreeViewer.java:684)

at org.eclipse.jface.viewers.AbstractTreeViewer.internalRefreshStruct(AbstractTreeViewer.java:1923)

at org.eclipse.jface.viewers.TreeViewer.internalRefreshStruct(TreeViewer.java:684)

at org.eclipse.jface.viewers.AbstractTreeViewer.internalRefresh(AbstractTreeViewer.java:1891)

at org.eclipse.jface.viewers.AbstractTreeViewer.internalRefresh(AbstractTreeViewer.java:1848)

at org.eclipse.ui.navigator.CommonViewer.internalRefresh(CommonViewer.java:527)

at org.eclipse.jface.viewers.StructuredViewer$8.run(StructuredViewer.java:1554)

at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1462)

at org.eclipse.jface.viewers.TreeViewer.preservingSelection(TreeViewer.java:366)

at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1423)

at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1551)

at org.eclipse.jface.viewers.ColumnViewer.refresh(ColumnViewer.java:534)

at org.eclipse.ui.navigator.CommonViewer.refresh(CommonViewer.java:347)

at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider$3.run(PackageExplorerContentProvider.java:957)

at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.runUpdates(PackageExplorerContentProvider.java:195)

at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider.runPendingUpdates(PackageExplorerContentProvider.java:187)

at org.eclipse.jdt.internal.ui.packageview.PackageExplorerContentProvider$1.runInUIThread(PackageExplorerContentProvider.java:165)

at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:97)

at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)

at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)

at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4155)

at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3772)

at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)

at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)

at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)

at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)

at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)

at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)

at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)

at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)

at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)

at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)

at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)

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:669)

at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)

at org.eclipse.equinox.launcher.Main.run(Main.java:1515)

at org.eclipse.equinox.launcher.Main.main(Main.java:1488)

We can add that OSGI framework never help someone to avoid UI freeze, it becomes even more difficult to track among all these bundles.

JRebirth has been designed to let developer doing a lot of task in background into a slot of ones of its thread pools, letting the UI thread peaceful to avoid UI freezes.

We can hope that Eclipse developers will use this tool to fix their code, avoiding this really bad UX.