Glossary

----
RSL
Runtime Shared Library. A block of code loaded before the application starts.
Signed RSL
A runtime shared libary that has been signed by Adobe and can be stored in the Player Cache. By convention signed RSLs have a .swz extension.
Unsigned RSL
A runtime shared library that has not been signed by Adobe. By convension these RSLs have a .swf extension.

Summary and Background

----
Linking RSLs by default means when we build an application swf, classes in framework.swc will not be included in the application. The classes instead will be loaded from the framework RSL just before the main application loads. In Flex 3 the default has been to statically link the classes while allowing the user to choose RSLs as an option. 

The advantage of using RSLs is smaller application swf sizes and faster download times. The downside is increased memory usage because all the framework classes are loaded, not just the ones you need.
 
To use RSLs by default requires updates in both the SDK and Flex Builder. The specification addresses the details of the SDK changes. In the SDK there are two major changes:
 
1. Modifying flex-config.xml to turn on RSL linking by default. Adobe signed swfs will be put on an Adobe server so third party web sites can use Adobe to provide bandwidth for downloading the RSLs. Some sites may not want to rely on Adobe and the old way of hosting a signed swf on your own site will still work.
2. Add an API to determine the RSL dependency order so Flex Builder can give the compiler the correct RSL load order.
 

Note that air-config.xml will not use RSL linking by default as AIR applications are often assumed to be wholly contained and usable offline.

Please see this write up (http://www.adobe.com/devnet/flex/articles/flash_player_cache_03.html) for information on how to use Flex3 RSLs in the SDK and Flash Builder.

Usage Scenarios

----
Jane compiles her application at the command line with the Flex 4 SDK. She notices the application size is much smaller than when it was compiled with the Flex 3 SDK (static linking was the default in Flex 3). She builds her application so that the RSLs are loaded from the Adobe web site.
 

Detailed Description

----

Changes to flex-config.xml

The flex-config.xml will be changed to reflect two changes in Flex 4.
1. Since Flash Player 10 is required to run Flex 4 applications the flex-config.xml will no longer need to specify an unsigned RSL as a failover.
2. Signed RSLs will be hosted by an Adobe Server.

The new RSL section of flex-config.xml will look something like this:

   <!-- TextLayout SWC -->
   <!--@@
   <runtime-shared-library-path>
      <path-element>libs/textLayout.swc</path-element>
      <rsl-url>${hosted.rsl.url}/flex/${build.number}/textLayout_${tlfbuild}.swz</rsl-url>
      <policy-file-url>${hosted.rsl.url}/crossdomain.xml</policy-file-url>
      <rsl-url>textLayout_${tlfbuild}.swz</rsl-url>
      <policy-file-url></policy-file-url>
   </runtime-shared-library-path>
      @@-->
   <!-- Framework SWC -->
   <!--@@
   <runtime-shared-library-path>
      <path-element>libs/framework.swc</path-element>
      <rsl-url>${hosted.rsl.url}/flex/${build.number}/framework_${build.number}.swz</rsl-url>
      <policy-file-url>${hosted.rsl.url}/crossdomain.xml</policy-file-url>
      <rsl-url>framework_${build.number}.swz</rsl-url>
      <policy-file-url></policy-file-url>
   </runtime-shared-library-path>
   @@-->
   <!-- Framework_textLayout SWC -->
   <!--@@
   <runtime-shared-library-path>
      <path-element>libs/framework_textLayout.swc</path-element>
      <rsl-url>${hosted.rsl.url}/flex/${build.number}/framework_textLayout_${build.number}.swz</rsl-url>
      <policy-file-url>${hosted.rsl.url}/crossdomain.xml</policy-file-url>
      <rsl-url>framework_textLayout_${build.number}.swz</rsl-url>
      <policy-file-url></policy-file-url>
   </runtime-shared-library-path>
   @@-->
   <!-- Flex4 SWC-->
   <!--@@
    <runtime-shared-library-path>
      <path-element>libs/flex4.swc</path-element>
      <rsl-url>${hosted.rsl.url}/flex/${build.number}/flex4_${build.number}.swz</rsl-url>
      <policy-file-url>${hosted.rsl.url}/crossdomain.xml</policy-file-url>
      <rsl-url>flex4_${build.number}.swz</rsl-url>
      <policy-file-url></policy-file-url>
   </runtime-shared-library-path>
         @@-->
   <!-- RPC SWC -->
   <!--@@
    <runtime-shared-library-path>
      <path-element>libs/rpc.swc</path-element>
      <rsl-url>${hosted.rsl.url}/flex/${build.number}/rpc_${build.number}.swz</rsl-url>
      <policy-file-url>${hosted.rsl.url}/crossdomain.xml</policy-file-url>
      <rsl-url>rpc_${build.number}.swz</rsl-url>
      <policy-file-url></policy-file-url>
   </runtime-shared-library-path>
      @@-->
   <static-link-runtime-shared-libraries>false</static-link-runtime-shared-libraries>

where

${hosted.rsl.url}

will be set to "http://fpdownload.adobe.com/pub/swz" and

${build.number}

is the SDK build number.

The Adobe Hosted RSL URL was put first in the list because we want applications to download from the Adobe Hosted website by default. Assuming the RSL can be down loaded from the site, an RSL will not be need to be deploy along with the application. Deploying an RSL locally is recommended as a fail over in case there is a problem getting the RSL from the Adobe server.

One issue is what happens when an application is being developed in Flash Builder and the user has no network connectivity. If the signed RSLs have already been cache, then there not be an issue. This issue is how long it takes to failover to the local copy of the RSL. In my testing I found the Flash Player would report a file not found error for a non-local RSL URL as follows:

  • one second if the server was not up and the load was attempted by a local swf file.
  • between two and three seconds to fail when the load was attempted by a remote application swf.

So, from Flex Builder we would see a one second delay per RSL. But this is only a one time event. Once the RSLs are loaded locally, they would be in the Flash Player Cache.

We are looking at the possibility of loading unsigned RSLs during debug builds. The unsigned RSL would be only available locally. This would make the build from Flex Builder without network connectivity a non-issue.

The static-link-runtime-shared-libraries option will be changed from true to false to enable RSL linkage by default. This will be done in all packaged SDKs. The static-link-runtime-shared-libraries option will remain true in the flex-config.xml file in the opensource repository. This will keep the default linkage as static for local builds. If there are no signed RSLs in an SDK then the RSL URLs in flex-config.xml will be modified to point to unsigned RSLs.

SWC Dependencies

The compiler will provide an API to answer questions about the dependencies between a set of SWCs. Flex Builder is expected to call the API to set the default order of its library path. The library path is based on SWC dependencies because Flex Builder tells the compiler what the RSL load order is based on the order of the SWCs in its library path. Anytime a SWC's linkage is changed to RSL it will be loaded in the correct order. Assuming all dependent RSLs are also being loaded, there won't be any RSL load issues. If needed, Compiler API can be added to answer the question of what additional RSLs are needed if a given RSL is loaded.

A new tool to show SWC dependencies, swcdepends, has been created. By default the tool outputs a list of SWCs ordered by dependencies. For each SWC in the list, a sub-list of SWCs the SWC is dependent on is shown. In addtion to the options supported by mxmlc the following options are available:

-dependency.show-external-classes
-dependency.show-swcs [swc-name] [...]
-dependency.show-types
-dependency.types [type] [...]

dependency.show-external-classes

When set to true this option shows what classes are causing a dependency from one SWC to another (false by default).

dependency.show-swcs

Limits the output to show just the given SWCs. Does not change the set of SWCs used to determine dependencies.

dependency.show-types

The dependency type(s) of a class.

dependency.types

Limits the dependency checking to just the types specified. By default all the dependency types are specified. This option is useful when you want to see what RSLs are needed by the RSL from a given SWC A. You can specify "i" to see all the SWCs that have an inheritance dependency on SWC A. Some or all of the dependent SWCs will need be RSLs as well so ensure that the required classes are loaded before the RSL for SWC A is loaded. The set of types is:

  • "i" - inheritance
  • "n" - namespace
  • "s" - signature
  • "e" - expression

Multiple dependency types can be specified like this:
-dependency.types=i,e

which would limit the dependency check to external classes with either inheritance or expression dependency types.

API Description

----

Compiler OEM API

The intended user of this API is Flex Builder to set the order of the its Library Path.

    /**
     * Get the dependency order of a given set of libraries.
     * 
     * @param libraries The set of libraries to find the dependency information for. Each
     * File in the list must be a library file or a directory of libraries files.
     * 
     * @return An ordered list of library dependencies. Each String in the 
     * list is the location of a library in the file system. The first library in the list has no
     * dependencies. Each library in the list has at least the same dependencies as its 
     * predecessor and may be dependent on its predecessor as well. 
     */
    public static List<String> getDependencyOrder(File[] libraries) throws CircularLibraryDependencyException
   
     /**
     * Get the set of library dependencies of a given library.
     * 
     * @param libraries The set of libraries need to resolve all the dependencies of the targetLibrary. Each
     * File in the list must be a library file or a directory of libraries files.
     * @param targetLibrary The libraries to find dependencies for.
     * @param minimizeDependencySet If false, all of the libraries dependencies are returned. If true, the external script
     * classes are reviewed. If the set of script classes resolved in a libraryA is a subset of the script
     * classes resolved in libraryB, then libraryA will be removed as a dependency of targetLibrary.
     * @return A set of Strings; where each String is the location of a library in the file system. 
     */
    public static Set<String> getLibraryDependencies(File[] libraries, 
            File targetLibrary, 
            boolean minimizeDependencySet) throws CircularLibraryDependencyException 


Examples and Usage

----

Compiler API for SWC Dependencies

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import flex2.compiler.util.ThreadLocalToolkit;
import flex2.tools.oem.Toolkit;

public class SwcDependsTest
{

    public static void main(String[] args)
    {
        List<File> files = new ArrayList<File>();
        
        System.out.println("Input:");
        for (int i = 0; i < args.length; i++)
        {
            System.out.println(args[i]);
            files.add(new File(args[i]));
        }
        
        System.out.println("Swc Dependency Order:");
        List<String> swcOrder = Toolkit.getSwcDependencyOrder(files.toArray(new File[files.size()]));
        
        for (String swcLocation : swcOrder)
        {
            System.out.println(swcLocation);
        }
        
        System.exit(ThreadLocalToolkit.errorCount());
    }
}

swcdepends

Running swcdepends from the command line with no options gives the below output. Each non-indented line is a SWC found via one of the compiler options. The non-indented line is sorted by dependency, from SWCS with the least dependencies to SWCs with the most dependencies. For each SWC the list of SWCs it is dependent on is output in an indented list.

Loading configuration file C:\opensource\sdk\trunk\frameworks\flex-config.xml
C:\opensource\sdk\trunk\frameworks\libs\player\10\playerglobal.swc:
C:\opensource\sdk\trunk\frameworks\libs\flex.swc:
	C:\opensource\sdk\trunk\frameworks\libs\player\10\playerglobal.swc
C:\opensource\sdk\trunk\frameworks\libs\framework.swc:
	C:\opensource\sdk\trunk\frameworks\libs\player\10\playerglobal.swc
C:\opensource\sdk\trunk\frameworks\libs\textLayout_core.swc:
	C:\opensource\sdk\trunk\frameworks\libs\player\10\playerglobal.swc
C:\opensource\sdk\trunk\frameworks\locale\en_US\framework_rb.swc:
	C:\opensource\sdk\trunk\frameworks\libs\player\10\playerglobal.swc
C:\opensource\sdk\trunk\frameworks\locale\en_US\airframework_rb.swc:
	C:\opensource\sdk\trunk\frameworks\libs\player\10\playerglobal.swc
C:\opensource\sdk\trunk\frameworks\locale\en_US\flex4_rb.swc:
	C:\opensource\sdk\trunk\frameworks\libs\player\10\playerglobal.swc
C:\opensource\sdk\trunk\frameworks\locale\en_US\rpc_rb.swc:
	C:\opensource\sdk\trunk\frameworks\libs\player\10\playerglobal.swc
C:\opensource\sdk\trunk\frameworks\libs\textLayout_conversion.swc:
	C:\opensource\sdk\trunk\frameworks\libs\player\10\playerglobal.swc
	C:\opensource\sdk\trunk\frameworks\libs\textLayout_core.swc
C:\opensource\sdk\trunk\frameworks\libs\utilities.swc:
	C:\opensource\sdk\trunk\frameworks\locale\en_US\framework_rb.swc
	C:\opensource\sdk\trunk\frameworks\libs\flex.swc
	C:\opensource\sdk\trunk\frameworks\libs\player\10\playerglobal.swc
	C:\opensource\sdk\trunk\frameworks\libs\framework.swc
	C:\opensource\sdk\trunk\frameworks\locale\en_US\airframework_rb.swc
	C:\opensource\sdk\trunk\frameworks\locale\en_US\flex4_rb.swc
	C:\opensource\sdk\trunk\frameworks\locale\en_US\rpc_rb.swc
C:\opensource\sdk\trunk\frameworks\libs\rpc.swc:
	C:\opensource\sdk\trunk\frameworks\locale\en_US\framework_rb.swc
	C:\opensource\sdk\trunk\frameworks\libs\flex.swc
	C:\opensource\sdk\trunk\frameworks\libs\player\10\playerglobal.swc
	C:\opensource\sdk\trunk\frameworks\libs\framework.swc
	C:\opensource\sdk\trunk\frameworks\locale\en_US\airframework_rb.swc
	C:\opensource\sdk\trunk\frameworks\locale\en_US\flex4_rb.swc
	C:\opensource\sdk\trunk\frameworks\locale\en_US\rpc_rb.swc
C:\opensource\sdk\trunk\frameworks\libs\textLayout_edit.swc:
	C:\opensource\sdk\trunk\frameworks\libs\player\10\playerglobal.swc
	C:\opensource\sdk\trunk\frameworks\libs\textLayout_conversion.swc
	C:\opensource\sdk\trunk\frameworks\libs\textLayout_core.swc
C:\opensource\sdk\trunk\frameworks\libs\textLayout_textField.swc:
	C:\opensource\sdk\trunk\frameworks\libs\player\10\playerglobal.swc
	C:\opensource\sdk\trunk\frameworks\libs\textLayout_core.swc
	C:\opensource\sdk\trunk\frameworks\libs\textLayout_conversion.swc
C:\opensource\sdk\trunk\frameworks\libs\flex4.swc:
	C:\opensource\sdk\trunk\frameworks\locale\en_US\framework_rb.swc
	C:\opensource\sdk\trunk\frameworks\libs\flex.swc
	C:\opensource\sdk\trunk\frameworks\libs\player\10\playerglobal.swc
	C:\opensource\sdk\trunk\frameworks\libs\textLayout_edit.swc
	C:\opensource\sdk\trunk\frameworks\libs\framework.swc
	C:\opensource\sdk\trunk\frameworks\libs\textLayout_core.swc
	C:\opensource\sdk\trunk\frameworks\libs\textLayout_conversion.swc
	C:\opensource\sdk\trunk\frameworks\locale\en_US\airframework_rb.swc
	C:\opensource\sdk\trunk\frameworks\locale\en_US\flex4_rb.swc
	C:\opensource\sdk\trunk\frameworks\locale\en_US\rpc_rb.swc
C:\opensource\sdk\trunk\frameworks\libs\framework_textLayout.swc:
	C:\opensource\sdk\trunk\frameworks\locale\en_US\framework_rb.swc
	C:\opensource\sdk\trunk\frameworks\libs\flex.swc
	C:\opensource\sdk\trunk\frameworks\libs\player\10\playerglobal.swc
	C:\opensource\sdk\trunk\frameworks\libs\framework.swc
	C:\opensource\sdk\trunk\frameworks\libs\textLayout_textField.swc
	C:\opensource\sdk\trunk\frameworks\locale\en_US\airframework_rb.swc
	C:\opensource\sdk\trunk\frameworks\locale\en_US\flex4_rb.swc
	C:\opensource\sdk\trunk\frameworks\locale\en_US\rpc_rb.swc

You must be logged in to comment.
  1. Nov 17

    Francis Potter says:

    There's a dead link on this page: http://www.adobe.com/devnet/flex/articles/flas...