Firebug 1.7: Architecture Refactoring

From FirebugWiki
Revision as of 07:35, 17 February 2010 by Johnjbarton (Talk | contribs) (Issue: SharedObject API)

Jump to: navigation, search

Problems to be Solved by Refactoring

  • Prepare to support remote debugging for mobile and multiprocess browser
    • Server side will be headless
    • Client side will have no access to Firefox data
  • Allow simpler and more robust extensions
    • Javascript oriented loading, no xpcom loader required
    • Isolation and concentration of extension code
  • Clean up expedient code and clarify the implementation
    • relation to platform window system,
    • relation of panels and modules
    • prepare/exploit shift to jetpack

Proposed Changes

Separate Modules and Panels

Broadly speaking Mike Collins' architecture for remote Firebug puts the module code in the server and the panel code in the client (UI side). The Firebug 'context' object (TabContext.js) is passed over the wire between them using CrossFire.

The first step in that direction is to divide all of the source into module and panel files. For example we might have debuggerModule.js and debuggerPanel.js. Then firebug.js would be divided between module dispatch and panel dispatch (dispatchModules.js and dispatchPanels.js?). The API between these objects would be the API CrossFire would remote.

Issue: file names vs folders

I understand the natural appeal of module/debugger.js and panel/debugger.js vs debuggerModule.js and debuggerPanel.js. However in my experience one needs to wrote with one kind of module plus panel much more often than all of the panels or all of the modules. Creating a subdirectory for each feature, eg debugger/module.js make lots of small folders. Any scheme where the folder is used to disambiguate makes lots of tools hard to use because you end up with a lot of UI selections like "module.js" or "debugger.js" and you can't tell what it means. That is how I ended up with debuggerModule.js and debuggerPanel.js: unambiguous naming with the feature first so alphabetic sort groups by feature.

Components replaced by SharedObjects

We currently have 5 XPCOM components. We need to create two more, Firebug and DOMWindowWatcher (see below). Since these are all in Javascript, the XPCOM infrastructure only exists to arrange common access between Firebug windows. By creating a single SharedObject XPCOM component we can reduce the amount of boiler plate code and clarify the design. This will also prepare for in-place JS editing and dynamic update features in future.

Issue: SharedObject API

Leverage work by CommonJS

This would put us on the same path as jetpack proposals.

As far as I know the CommonJS, as well as Mozilla platform Components.utils.module, supports common code loading, but we want common object sharing. So there may be some additional work on API.

Recode TabWatcher -> DOMWindowWatcher

I think we now pretty much understand TabWatcher, but it is still very heuristic and relies on Firefox idiosyncrasies that can change. Chromebug has its own watcher and even more guesses about the platform. Let's replace all of that with a clean abstraction for nsIXULWindow and nsIDOMWindow lifetime event notifications. Then put it in a SharedObject so we only need one per application and we have clearer API.

This requires platform support

Issue: DOMWindowWatcher API

Ideally we would mimic/influence jetpack here, as they have a subset of the same problem.

Sandboxed Extension Loading

By re-applying the module loading technology we can create a jetpack-like environmental wrapper for Firebug extensions. The extensions would be slightly simpler because they would just be zip files. They would be slightly more robust because they would be evaled in a scope that only contains Firebug.

Dependent on Firefox Improvements

Memory Panel

This is one of top features. This has be requested many times and would be certainly very helpful for web app developers.

Bug 515946 - jsd: Add support for memory profiling.

TabWatcher refactoring

Have a solid Firefox event that is always fired (at the right time) when a new document is loading (no matter if it’s a web page, xslt, about:blank, etc.) and used to initialize page context for Firebug (i.e. call initContext). This is also one of the top things (for a long time).

Bug 342715 - Need an API to allow extensions to hook "document load started" events

This should also help to significantly simplify the TabWatcher, which is one of the basic (and most hacky) drivers in Firebug (controls life cycle of the UI).

Add Support for Compilation Units to jsd/firebug-service

Bug 449464 - Implement jsdICompilationUnit to extend jsd to include information on the compilation unit structure

How to Particiapate