Using Flex Hero RSL Enhancements

Posted on August 27, 2010 | 4 comments

One of the new features of the Flex Hero SDK is RSL Enhancements. I wanted to understand what this new feature really means for Flex projects and applications. The following post will show the differences in Flash Builder 4 projects and then use a custom Flex 4 preloader to display timed text information about what really is going on in the RSL loading process.

Source Code Used in the Post
Flex Hero SDK
RSLTest4_0.fxp
RSLTestHero.fxp

Content

If you haven’t read the RSL Enhancements Flex SDK specification page here is the quick summary. The new features allows for you to set a compiler arguments for mxmlc to control rsl loading, be it forcing a rsl to load or ignore unused rsl’s. And for compc you can set a compiler option to include only the inheritance dependencies of a set of classes specified in the include-classes option. This allows for monkey-patched classes to be delivered as rsl patches on top of the signed rsl’s instead of having to include the core code in your custom rsl. One last thing is the separation of the framework.swf (included mx components) rsl into two rsl’s: framework.swf and mx.swf. This is an improvement for spark only projects.

Flash Builder 4 Projects Differences
I created two projects, RSLTest4_0 and RSLTestHero, one pointing to Flex 4 SDK and the other Flex Hero SDK. They are the default Flex application with nothing in it. I had to switch Flex Hero SDK’s build options to use RSL (currently the default is on to merge which is not necessarily how it will ship). Once both projects where build with default applications and RSL on the Flex SDK turned on this is what you see:

You’ll see that in the RSLTestHero project the new mx rsl is there (the highlighted one).

Ok that part of the feature is verified. Now to test the new compiler argument of -remove-unused-rsls=true. First you need to open up the RSLTestHero project’s properties panel and add in the Flex Compiler -> Compiler options section the new compiler argument. See below for a picture of what I am talking about:

Now this doesn’t actually remove the rsl’s from the bin-debug folder. This leaves us with no real way to test what changes are going on, hence the need for a custom preloader to get to the meat of it.

Custom Flex 4 Preloader – com.renaun.preloader.TimedPreloader
I have included the source code for the custom Flex 4 preloader that I created. It basically reports event information based on time (getTimer()) relative to the initialize() call on preloader. Flex preloaders give you all kinds of information about the swf, rsl loading process, and validation of the initialize phases. The custom preloader display text on the screen (as well as sends traces out). Hooking into the relevant information and spitting it out, this is what the trace statements look like:

RSLTestHero with -remove-unused-rsls=true

[117] Progress: 162324/327144
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTestHero:bin-debug:RSLTestHero.swf:[[DYNAMIC]]:1 - 650,777 bytes after decompression
[174] Progress: 327144/327144
[177] RSL Complete: 1/3 Bytes: 263124
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTestHero/bin-debug/textLayout_1.1.0.604.swf
[185] Progress: 425448/852844
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTestHero:bin-debug:RSLTestHero.swf:[[DYNAMIC]]:2 - 1,185,241 bytes after decompression
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTestHero:bin-debug:RSLTestHero.swf - 144,240 bytes after decompression
[278] Progress: 852844/852844
[279] RSL Complete: 2/3 Bytes: 525700
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTestHero/bin-debug/framework_4.5.0.17077.swf
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTestHero:bin-debug:RSLTestHero.swf:[[DYNAMIC]]:3 - 1,705,612 bytes after decompression
[405] Progress: 1468083/1468083
[407] RSL Complete: 3/3 Bytes: 615239
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTestHero/bin-debug/spark_4.5.0.17077.swf
[411] Progress: 1468083/1468083
[442] Progress: 1468083/1468083
[572] Complete
[573] Initialize Event #1
[610] Initialize Event #2
[640] Initialize Event #3
[670] Initialize Event #4



RSLTestHero with -remove-unused-rsls=false

[103] Progress: 162665/284697
[110] Progress: 260969/284697
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTestHero:bin-debug:RSLTestHero.swf:[[DYNAMIC]]:1 - 529,577 bytes after decompression
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTestHero:bin-debug:RSLTestHero.swf - 145,017 bytes after decompression
[197] Progress: 284697/284697
[202] RSL Complete: 1/7 Bytes: 220336
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTestHero/bin-debug/osmf_1.0.0.16316.swf
[209] Progress: 383001/547821
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTestHero:bin-debug:RSLTestHero.swf:[[DYNAMIC]]:2 - 650,777 bytes after decompression
[299] Progress: 547821/547821
[302] RSL Complete: 2/7 Bytes: 263124
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTestHero/bin-debug/textLayout_1.1.0.604.swf
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTestHero:bin-debug:RSLTestHero.swf:[[DYNAMIC]]:3 - 1,185,241 bytes after decompression
[401] Progress: 1073521/1073521
[403] RSL Complete: 3/7 Bytes: 525700
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTestHero/bin-debug/framework_4.5.0.17077.swf
[412] Progress: 1171825/1601503
[423] Progress: 1368433/1601503
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTestHero:bin-debug:RSLTestHero.swf:[[DYNAMIC]]:4 - 1,143,269 bytes after decompression
[532] Progress: 1601503/1601503
[534] RSL Complete: 4/7 Bytes: 527982
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTestHero/bin-debug/mx_4.5.0.17077.swf
[544] Progress: 1699807/1809574
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTestHero:bin-debug:RSLTestHero.swf:[[DYNAMIC]]:5 - 443,950 bytes after decompression
[559] Progress: 1809574/1809574
[572] Progress: 1809574/1809574
[634] Progress: 1809574/1809574
[636] RSL Complete: 5/7 Bytes: 208071
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTestHero/bin-debug/rpc_4.5.0.17077.swf
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTestHero:bin-debug:RSLTestHero.swf:[[DYNAMIC]]:6 - 1,705,612 bytes after decompression
[787] Progress: 2424813/2424813
[789] RSL Complete: 6/7 Bytes: 615239
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTestHero/bin-debug/spark_4.5.0.17077.swf
[795] Progress: 2424813/2424813
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTestHero:bin-debug:RSLTestHero.swf:[[DYNAMIC]]:7 - 323,813 bytes after decompression
[839] Progress: 2494673/2494673
[841] RSL Complete: 7/7 Bytes: 69860
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTestHero/bin-debug/sparkskins_4.5.0.17077.swf
[857] Progress: 2494673/2494673
[878] Progress: 2494673/2494673
[991] Complete
[992] Initialize Event #1
[1025] Initialize Event #2
[1050] Initialize Event #3
[1080] Initialize Event #4



RSLTest4_0

[34] Progress: 161056/1099861
[110] Progress: 259360/1099861
[155] Progress: 849184/1099861
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTest4_0:bin-debug:RSLTest4_0.swf:[[DYNAMIC]]:1 - 2,292,131 bytes after decompression
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTest4_0:bin-debug:RSLTest4_0.swf - 142,610 bytes after decompression
[293] Progress: 1099861/1099861
[297] RSL Complete: 1/6 Bytes: 1037109
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTest4_0/bin-debug/framework_4.0.0.14159.swf
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTest4_0:bin-debug:RSLTest4_0.swf:[[DYNAMIC]]:2 - 370,463 bytes after decompression
[343] Progress: 1250592/1250592
[346] RSL Complete: 2/6 Bytes: 150731
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTest4_0/bin-debug/osmf_flex.4.0.0.13495.swf
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTest4_0:bin-debug:RSLTest4_0.swf:[[DYNAMIC]]:3 - 648,239 bytes after decompression
[420] Progress: 1512818/1512818
[422] RSL Complete: 3/6 Bytes: 262226
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTest4_0/bin-debug/textLayout_1.0.0.595.swf
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTest4_0:bin-debug:RSLTest4_0.swf:[[DYNAMIC]]:4 - 441,686 bytes after decompression
[472] Progress: 1720358/1720358
[475] RSL Complete: 4/6 Bytes: 207540
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTest4_0/bin-debug/rpc_4.0.0.14159.swf
[479] Progress: 1720358/1720358
[493] Progress: 1916966/2221609
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTest4_0:bin-debug:RSLTest4_0.swf:[[DYNAMIC]]:5 - 1,429,050 bytes after decompression
[576] Progress: 2221609/2221609
[577] RSL Complete: 5/6 Bytes: 501251
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTest4_0/bin-debug/spark_4.0.0.14159.swf
[SWF] Users:renaun:Documents:workspaces:BlogProjects:RSLTest4_0:bin-debug:RSLTest4_0.swf:[[DYNAMIC]]:6 - 323,414 bytes after decompression
[631] Progress: 2291414/2291414
[632] RSL Complete: 6/6 Bytes: 69805
file:///Users/renaun/Documents/workspaces/BlogProjects/RSLTest4_0/bin-debug/sparkskins_4.0.0.14159.swf
[643] Progress: 2291414/2291414
[661] Progress: 2291414/2291414
[792] Complete
[792] Initialize Event #1
[829] Initialize Event #2
[855] Initialize Event #3
[888] Initialize Event #4



A few things here, you see that with the new compiler argument RSLTestHero only loads 3 rsl’s intead of 7. Less RSL’s to load mean faster load times! The Flex 4 sdk loaded 6 instead of the new 7 in Flex Hero with no unused rsl’s where removed, which reflects the new mx.swf rsl.

Have fun playing with the new feature and try out the custom preloader on your own application to see what is really happening. I didn’t show the compc dependency class listing feature here, but using the custom preloader is a great way to verify the monky-patching rsl’s as they can now be dependent on other rsl.