RSLs - What Are They, How Do I Use Them, and Why Isn't Mine Working?

In this post we are going to examine the ins and outs of Runtime Shared Libraries. Runtime Shared Libraries (RSLs) are compiled libraries of code that allow you to cache functionality into the browser or Flash Player. One of the most common uses of RSLs are the Framework RSLs included in the Flex Framework, used to cache the Flex Framework. This can potentially speed load times. These Framework RSLs are the topic of today's post.

There are two types of Framework RSLs, signed and unsigned.

The SWF RSLs are unsigned libraries. These get cached into the browser because they are untrusted. What does this mean? It means that the code contained within has not been signed/verified by the publisher to be safe, and therefore can only be used by the applications that have access to the RSL's domain. This also means that if you use the SWF version of the RSL, a visitor must load that RSL if they have never obtained that RSL from your domain previously. Even if that user has been to another site using the same SDK version, the RSL will not be cached for them.

The SWZ version of the RSLs are signed, and have been verified by the publisher to be safe and trusted. What does this mean to you? The biggest advantage is that these are accessible cross-domain. It allows you to provide the RSL to the user if they have never downloaded the RSL from another source previously. But, if the user has visited any other site using the same framework version and that site provided the SWZ version of the RSL, that user does not have to download the RSL from your domain. It is already cached into the  Flash Player and is available for use. This potentially saves a significant amount of download time, as the RSLs can be rather large (relatively speaking, of course).

So, given what we know so far, SWZ RSLs seem to be the way to go. Bear in mind that only Adobe can create signed RSLs. The caveat here is that I have often run into instances where Adobe has not properly packaged the RSLs into the Flex Framework. Since I only use the SWZ RSLs, this has forced me to use a different version of the framework than I intended to use at the start of a project.

Its generally not difficult to change your SDK version. However, it can be annoying to go through the entire process just to discover the SDK doesn't have those SWZ files. The best way to troubleshoot this is to verify that your project contains the proper RSL files when you export your release build (discussed later). These are named similar to this: framework_3.4.0.9271.swz. The "framework" appearing before the underscore is the RSL name, the numbers after the underscore is the SDK version. All RSLs in your project must match the SDK version your project was compiled with.

Since there are a number of SWC libraries that comprise the Flex framework that you can cache as RSLs, you will need to decide which are appropriate for your project. The three that I am currently aware of are:

  • Framework - contains the bulk of the Flex framework
  • RPC - contains the classes necessary for RemoteObject, WebService and other RPC operations.
  • Data Visualization - contains the classes for the data visualization components (charts, graphs, etc)

So how do we set up RSLs? I know that's what you've been waiting for, so let's just get to it! I am going to base these steps on the assumption that you are using Flash Builder standalone or as an Eclipse Plugin. I'm using the latter and the steps should be almost exactly the same for Flash Builder standalone.

The first step is to configure your web server. Ya, I'm sure you were expecting me to just start showing you how to set these up in your project. However, this next step is critical and often missed. The SWZ MIME type is not included in any web server I know of, so you will need to add this manually in order for SWZ files to be recognized. If you miss this step you will either get an RSL error or the movie will fail over to the SWF version, if you have included it. The trick here is to create a new MIME type for .swz that has the same properties as the existing .swf MIME type (application/x-shockwave-flash swf).

For Apache, I have found this link which explains the process of adding MIME types. I have not verified this is correct, so if it is not please let me know and I will find a good link. For IIS, this process varies from version to version. For IIS 6 use this link. For IIS 7 and IIS 7.5 this is the correct process.

Now that you have your MIME type configured, let's get to the juicy stuff: adding RSLs to your project!

The first step is to right click on your Flex project and choose "Properties". From the panel, choose "Flex Build Path", then select the "Library Path" tab. In the "Build path libraries" list, expand the "Flex {version number}" folder. The version number will be the same as the SDK you are using in your project. This screen capture show that I have expanded my Flex 3.5 folder.

Flex Build Path

Expand the "framework.swc" node. You will notice that the display provides you with the information to quickly know how a library is linked. This is a simple way to determine if the project you are working on has been properly linked. Now select the "RSL" element from the list within.

With "RSL" element highlighted, select the "Edit" button. In the dialogue that appears, deselect the "Use same linkage as framework" option. The options within "Link Type" now become available to you. From this list, select "Runtime Shared Library (RSL)". Next, select the "Digests (recommended)" option in the "Verification" selections.

Now that you have configured the RSL settings, you will link the SWZ file to the "Deployment Paths" list. This may already be done for you. If so, please verify that the linked RSL is the correct version for your SDK. Next, remove the SWF version. This step is not really necessary, but if you truly wish to use the sign RSLs (SWZ), removing the SWF version will cause an RSL error at runtime if the SWZ RSLs are failing. This allows you to be fully aware that the SWZ RSLs are having an issue. If you keep the SWF version linked and the SWZ version fails, it will default to the SWF RSL. When you are done, it should look something like this:

RSL configuration

Click "OK". You have now completed configuring the Flex framework RSL. Repeat this for the RPC and DataVisualization libraries if you use those classes.

If you have issues with RSLs working in your development environment, you may wish to use the "Use local debug runtime shared libraries when debugging" option on the main "Flex Build Path" screen, which I have highlighted below in red. This will allow you to use the standard SWF libraries in debug mode.

Flex Build Path 2

These instructions have worked for me countless times, but you may experience various problems with RSLs. I may have even missed a step or two! If so, please let me know and I'll update this post.

One helpful thing I have found is to be certain that your SDK contains the proper SWZ files before you start trying to link them, as I mentioned previously in this post. To check this, go into your FlexBuilder installation folder (this varies depending on your OS and which version of Flex you have installed) and look in the following folder: sdks/{version number}/frameworks/rsls. You should see, at a minimum, three SWZ files. There should be one for Data Visualization, one for RPC and one for Framework. If these files do not exist then you will need to use a different version of the SDK.

If you are still getting errors, check this link:  Troubleshooting RSLs. I have found this link helpful to troubleshooting RSL errors in the past.

I hope you find this post useful, and if you have anything to add I'll be happy to consider it!

Tags: Flex, Flash & AS3

9 responses so far ↓

  • 1 Tothy // Feb 22, 2010 at 11:46 PM

    I heard RSL's and HTTPS-sites does not match very good, or, not at all. Can you confirm or refute this?
  • 2 Alex // Feb 22, 2010 at 11:47 PM

    very useful!
    Thanks!
  • 3 TJ Downes // Feb 23, 2010 at 6:10 AM

    Hi Tothy

    I use RSL with SSL sites frequently. I have not experienced any issues on this front. The RSL loads via a relative path, so you should be fine under HTTP or HTTPS
  • 4 Chetan Sachdev // May 9, 2010 at 12:35 AM

    Nice article. I have used RSLs a number of times, but haven't configured the Apache or IIS server(while, i have deployed on both). Is it necessary to configure it, what problems, should I face so that I can confirm, if server is configured properly or not..
  • 5 TJ Downes // May 11, 2010 at 9:21 AM

    Hello Chetan

    Sorry its taken a couple of days to respond, I started a new job and have been busy with that.

    The only thing you should need to configure are MME typee. This is well documented forboth Apache and IIS. The MIME type you will need to add is for the swz extension and it will have the same type as swf.

    Generally, to ensure the server is configured properly, I will make sure that only swz RSLs are configured on the project. If there is an issue with the server config you will get an RSL error in your SWF at load time.

    TJ
  • 6 Vijay Mareddy // Jun 1, 2010 at 1:35 PM

    Where do i configure the build.number property in my Flex Builder.
    I have framework_${build.number}.swz
  • 7 TJ Downes // Jun 2, 2010 at 1:47 PM

    Hello Vijay

    You point your RSL configuration at the RSL files that are included in the framework. To do this, go to Project properties, Flex Build Path, Library Path and set the RSLs for the libraries in that list.
  • 8 JC // Dec 6, 2010 at 5:30 AM

    TJ,

    Thanks for sharing and clarifying – heaven forbid Adobe documentation should be this lucid. Excellent job!
  • 9 jonny rocket // Sep 18, 2012 at 10:54 AM

    when using firefox for a session i always delete them. this is what the really paranoid browser users do. that way zuckerberg and google can't watch me cross-site wise.

Leave a Comment

Leave this field empty: