Remember your imports!

One of the most common configuration errors people make is to forget to import the necessary interfaces for a bundle:

<manifest xmlns="http://ns.adobe.com/gravity/manifest/1.0"> 
 
  <interface location="foo_interface.swf"> 
    <exports> 
      <export name="com.example.IFoo"/> 
    </exports> 
  </interface> 
 
  <bundle location="some_bundle.swf"> 
    <imports>
      <import name="com.example.IFoo"/>
    </imports>
  </bundle> 
  
  <bundle location="other_bundle.swf"> 
    <!-- forgot to import IFoo -->
  </bundle> 
  
</manifest>

Such errors may not be immediately apparent as some other bundle that happens to be loaded earlier may happen to import the same interfaces: so long as the interface SWF happens to be loaded before any bundles that require it are loaded, everything will work, since interface SWFs are loaded into the root ApplicationDomain. However, since bundles are loaded in parallel when possible, this can lead to race conditions where the failure is very intermittent since so many different factors come into play: operating system, browser and browser version, network topology, contents of the browser cache, and more. You can experiment with the effects of load ordering with this multiple ApplicationDomain demo.

If you have this issue, it will typically manifest as a failure to find the service that wasn’t imported. If you find yourself thinking, “I can see that the service is registered, why is my lookup failing?” then this is probably the problem.

If you optimize your bundles by excluding the service interfaces, it will show up as a VerifyError, which makes it a little easier to diagnose.

Note that the same issue can occur between interface SWFs if one interface SWF depends on another. Interface SWFs also need to declare imports if they depend on interfaces defined in other interface SWFs:

<manifest xmlns="http://ns.adobe.com/gravity/manifest/1.0"> 
 
  <interface location="foo_interface.swf"> 
    <exports> 
      <export name="com.example.IFoo"/> 
    </exports> 
  </interface> 
 
  <interface location="bar_interface.swf"> 
    <exports> 
      <export name="com.example.IBar"/> 
    </exports> 
    <imports>
      <!-- IBar has methods or properties that reference IFoo,
           or IBar extends IFoo, so we need to import IFoo -->
      <import name="com.example.IFoo"/>
    </imports>
  </interface> 
</manifest>