From MozillaWiki
Jump to: navigation, search

The XPCOM bootstrap process is overly complicated and time-consuming. I'd like to take the following actions to simplify it:

This work is complete, NS_InitEmbedding has been removed.

State Management

The XPCOM startup and shutdown sequences are very state-sensitive: you must release objects in certain orders, and end threads by a certain point, etc. This is currently managed entirely through observers... in many cases it would be simpler and better to have a global XPCOM state:

enum XPCOMState {

State transitions would be managed entirely by the bootstrap code, and code throughout the tree would be able to do simple sanity-checks, e.g.:

  • don't spin the event loop except during certain states
  • don't create windows, or reflow, or fire any DOM events during shutdown
  • don't fire DNS resolution events after XPCOM has started shutting down


Move component registration to chrome.manifest.

Component registration currently requires loading all our modules and asking each one programmatically which components it implements. This is time-consuming and requires XPCOM to restart after it has been completed.

The only two things you should need to do during registration is register contractIDs/CIDs and add category entries.

I'd like to move component registration into the chrome.manifest files to be declarative lines:

component <CID> <file>
contract <contractid> <CID>
category <category> <entry> <value>

For example, to register a single CID and contract:

component 550e8400-e29b-41d4-a716-446655440000 components/MyComponent.js
contract @foo.bar/my-component;1 550e8400-e29b-41d4-a716-446655440000

Potential pitfalls: currently components that fail to load (for instance because system libraries are not available) will not register at all. With declarative registration they will now be registered, but will fail to load.