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

Bug 328163

Summary: [contexts] Provide debug / trace functionality for context injection
Product: z_Archived Reporter: Oleg Besedin <ob1.eclipse>
Component: E4Assignee: Project Inbox <e4.runtime-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P3 CC: bokowski, emoffatt, ob1.eclipse, pwebster, remy.suen
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=534612
Whiteboard:
Attachments:
Description Flags
Screenshot of the tracing view
none
The trace / debug view
none
Patch that adds debug hooks to the Eclipse contexts
none
Patch: find new listeners
none
Patch: organize listeners by name
none
Patch: improved refresh of the context tree
none
Current screenshot none

Description Oleg Besedin CLA 2010-10-19 13:22:10 EDT
Debugging problems in contexts/DI combination is rather complicated. Let's see what tracing / visualization / debug helpers we can create to make it easier to understand contexts inner workings.
Comment 1 Oleg Besedin CLA 2010-10-19 13:31:13 EDT
Created attachment 181206 [details]
Screenshot of the tracing view
Comment 2 Oleg Besedin CLA 2010-10-19 13:33:50 EDT
Created attachment 181207 [details]
The trace / debug view

This bundle adds the contexts trace / debug view into the "Debug" category.
Comment 3 Oleg Besedin CLA 2010-10-19 13:34:39 EDT
Created attachment 181208 [details]
Patch that adds debug hooks to the Eclipse contexts
Comment 4 Oleg Besedin CLA 2010-10-19 13:47:41 EDT
The "Patch that adds debug hooks to the Eclipse contexts" is applied to CVS Head; the new trace/debug bundle is shared as:

  e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.core.contexts.debug

Any feedback is very welcome. At this point I am trying to figure out what's useful vs. what we can reasonably do, so all ideas about what information is needed to visualize context injection are very welcome.

In plans:

- organize links page by context keys
  [I'd like to change the actual EclipseContext to work that way too, for performance reasons.]

- add snapshot / diff for context listeners to help catch leaks

- see if we can make this into a true debug view (i.e., debugging out of process, breakpoints)
Comment 5 Oleg Besedin CLA 2010-10-22 11:55:18 EDT
Created attachment 181515 [details]
Patch: find new listeners

The patch adds a "Snapshot" for contexts and their listeners along with the code that detects new listeners created since the snapshot was taken.

Few points:

- having new listeners does not mean a leak by itself; only having new listeners after repeat operations might indicate a leak. (For example, having new listeners after context menu is shown for the first time is probably OK; having new listeners every time that context menu comes up needs to be checked);

- to reduce false positives, we only check contexts that existed both in the "snapshot" time and in the current state; we don't compare short-lived contexts created between those two points in time. While such contexts and their listeners should not affect DI operations, normal garbage collection concerns still apply.

(Patch applied to CVS Head.)
Comment 6 Oleg Besedin CLA 2010-11-01 13:40:54 EDT
Created attachment 182162 [details]
Patch: organize listeners by name

Now that I've made the change for the bug 329208, this patch displays context listeners organized by the value they depend on in the context.

(Patch applied to CVS Head.)
Comment 7 Oleg Besedin CLA 2010-11-01 16:44:46 EDT
Created attachment 182174 [details]
Patch: improved refresh of the context tree

The refresh of the context tree is now done in 5-second intervals (if "Auto" is enabled), or initiated by the "Refresh now" button.

The context values in the view are stored as weak references allowing proper garbage collection. 

(Patch applied to CVS Head.)
Comment 8 Oleg Besedin CLA 2010-11-01 16:47:49 EDT
Created attachment 182175 [details]
Current screenshot