Hero Size Report - Functional and Design SpecificationHero Size Report - Functional and Design Specification | Summary and Background | Usage Scenarios | Detailed Description | API Description | B Features | Examples and Usage | Additional Implementation Details | Prototype Work | Compiler Work | Web Tier Compiler Impact | Flex Feature Dependencies | Backwards Compatibility | Accessibility | Performance | Globalization | Localization | Issues and Recommendations | Documentation | QA
Summary and BackgroundThe Flex 3.x/4.0 compiler provides a -link-report option which generates an XML based report detailing all of the ActionScript class definitions included within the SWF, along with the approximate size in bytes of each. The legacy link report also provides detailed dependency information for each class. While very useful, the link report feature is somewhat limiting at times. For example, when analyzing a SWF during development it is sometimes useful to understand what beyond ActionScript bytecode contributes to the size of the file. Although it's possible to introspect a SWF using the SDK's swfdump utility, the swfdump report does not currently provide a high level summary suitable for quickly narrowing down problem areas related to SWF size. Flash Authoring has historically provided a publish-time 'size report' that presents an at-a-glance costing of all the ActionScript bytecode, fonts, images, sounds, videos, and other symbols within the resulting SWF. This report is useful when trying to reduce the size of your SWF, as you can identify specific bitmap or media assets which could be compressed further, or identify fonts which contain too many unnecessary glyphs. Flex 4.5 will introduce a new -size-report option useful for summarizing the 'cost' of each type data within the SWF (script, media, fonts, etc.). Usage ScenariosA developer notices that after embedding a series of image assets into his application, his SWF has grown to an unacceptable size. By utilizing the size report feature, he is able to quickly determine that a few of his images had a much larger size (in bytes) than the others. After adjusting the compression options for the specific embeds, and replacing others with vector assets, the developer was able to optimize his SWF size. A designer notices that after embedding (3) fonts, one of the fonts was accounting for many more bytes than the others. By limiting the range of embedded characters for the given font, the SWF size was greatly improved. Detailed DescriptionUsage: -size-report <filename>. When used with either mxmlc or compc, an XML size report will be generated containing the following data (if applicable): (All sizes are reported in bytes.) SummaryThe root report tag will contain a single swf tag, containing both the compressed and uncompressed size of the SWF (in bytes). <?xml version="1.0" encoding="UTF-8"?> <report> <swf size="584654" compressedSize="268252"> ... </swf> </report> [HeaderData]The size of the actual SWF file format header, product info, and various other marker data. <!-- Header data (SWF attributes, metadata, product info, SWF markers, etc.) --> <headerData totalSize="533"> <data type="metaData" size="465"/> <data type="productInfo" size="28"/> <data type="swfHeader" size="21"/> <data type="fileAttributes" size="6"/> <data type="scriptLimits" size="6"/> <data type="backgroundColor" size="5"/> <data type="endMarker" size="2"/> </headerData> Frame SummaryA frame by frame summary of all script and tag data for each frame. Flex applications usually consist of 2 or more frames, with the first frame containing all preloader logic as well as the top level SystemManager definition. <!-- Cumulative frame size summary. --> <frames totalSize="584121"> <frame name="_stest_mx_managers_SystemManager" size="50815" frame="1"/> <frame name="stest" size="533306" frame="2"/> </frames> ActionscriptThe ActionScript data associated with this SWF is detailed further in the actionScript portion of the report. For release mode swfs all ActionScript bytecode and constant pool data is consolidated into a single block within the frame that it is associated with. For debug mode swfs or debug swcs, the abc blocks are generally broken down by symbol. All entries are sorted largest to smallest. <!-- Actionscript code and constant data. --> <actionScript totalSize="570124"> <abc name="frame2" size="519385" frame="2"/> <abc name="frame1" size="50739" frame="1"/> </actionScript> Frame DataAdditional SWF tags related to frame definitions (frame labels, symbol definitions, export definitions, showFrame tags, etc.). <!-- Additional frame tags (symbolClass, exportAssets, showFrame, etc). --> <frameData totalSize="1211"> <tag type="symbolClass" size="586" frame="2"/> <tag type="exportAssets" size="539" frame="2"/> <tag type="symbolClass" size="39" frame="1"/> <tag type="frameLabel" size="35" frame="1"/> <tag type="frameLabel" size="8" frame="2"/> <tag type="showFrame" size="2" frame="1"/> <tag type="showFrame" size="2" frame="2"/> </frameData> Bitmap DataAll embedded bitmap data (corresponding internally to defineBits, definebitsJPEG2/3/4 or defineBitsLossless/2 tags) is detailed in the bitmaps section of the report. All entries are sorted largest to smallest. If appropriate, the symbol name of each bitmap is provided. Note: The original file name is not provided currently, as the information is not available at the time the tags are encoded. Possible future enhancement. <!-- defineBits, definebitsJPEG2/3/4, or defineBitsLossless/2 --> <bitmaps totalSize="19688"> <bitmap name="myApp_icon" size="19688" frame="2"/> </bitmaps> FontsAll embedded font data (corresponding internally to defineFont/2/3/4 tags) is detailed in the fonts section of the report. All entries are sorted largest to smallest. If appropriate, the symbol name of each font is provided. _Note: The original font face name or path is not provided currently, nor any enumeration of the embedded glyphs, as the information is not available at the time the tags are encoded. DefineFont4 format also does not allow easy enumeration of the embedded glyphs. Possible future enhancement._ <!-- defineFont/2/3/4. --> <fonts totalSize="61600"> <font name="myApp__embed__font_MyriadProItalic_medium_italic_1543977508" fontName="MyriadProItalic" size="31265" frame="2"/> <font name="myApp__embed__font_MyriadProBold_bold_normal_290064645" fontName="MyriadProBold" size="30335" frame="2"/> </fonts> Sprite DataAll sprite data (corresponding internally to the defineSprite tag) is detailed in the sprites section of the report. All entries are sorted largest to smallest. If appropriate, the symbol name of each sprite definition is provided. <!-- defineSprite. --> <sprites totalSize="19"> <sprite name="_stest_Styles__embed_css_Assets_swf_mx_skins_cursor_BusyCursor_1687245514" size="19" frame="2"/> </sprites>
$body
Shape DataAll shape data (corresponding internally to the defineShape/2/3/4 tags) is detailed in the shapes section of the report. All entries are sorted largest to smallest. If appropriate, the symbol name of each shape definition is provided. <!-- defineShape/2/3/4. --> <shapes totalSize="261"> <shape size="261" frame="2"/> </shapes> Binary DataAll generic binary data (corresponding internally to the defineBinaryData tag) is detailed in the binaryData section of the report. This could include embedded SWFs, Pixel Bender shaders, or any other miscellaneous embed data. All entries are sorted largest to smallest. If appropriate, the symbol name of each data definition is provided. Note: The original file name for each asset is not provided currently as the information is not available at the time the tags are encoded. Possible future enhancement. <!-- SWF, Pixel Bender, or other miscellaneous embed data. --> <binaryData totalSize="2298"> <data name="mx.graphics.shaderClasses.SaturationShader_ShaderClass" size="2298" frame="2"/> </binaryData> Sound DataAll embedded sound data (corresponding internally to defineSound tag) is detailed in the sounds section of the report. All entries are sorted largest to smallest. If appropriate, the symbol name of each sound is provided. Note: The original file name for each asset is not provided currently as the information is not available at the time the tags are encoded. Possible future enhancement. <!-- defineSound --> <sounds totalSize="2983"> <sound name="myApp_ding" size="2983" frame="2"/> </sounds> Video DataAll embedded video data (corresponding internally to defineVideoStream tag) is detailed in the videos section of the report. All entries are sorted largest to smallest. If appropriate, the symbol name of each video asset is provided. Note: The original file name for each asset is not provided currently as the information is not available at the time the tags are encoded. Possible future enhancement. Note also that currently the Flex SDK provides no means of embedding FLV or video stream data directly. <!-- defineVideoStream --> <videos totalSize="28900"> <video name="myApp_loop" size="28900" frame="2"/> </videos> API DescriptionNot applicable. B FeaturesThe following features would require a bit too much refactoring of the compiler to support for the initial version of this feature:
Examples and UsageUsage: -size-report <filename>. Example: The following is a size report generated from [HelloWorld].mxml with RSL linkage enabled.
$body
<?xml version="1.0" encoding="UTF-8"?> <report> <swf size="74624" compressedSize="38485"> <!-- Header data (SWF attributes, product info, markers, etc.) --> <headerData totalSize="533"> <data type="metaData" size="465"/> <data type="productInfo" size="28"/> <data type="swfHeader" size="21"/> <data type="fileAttributes" size="6"/> <data type="scriptLimits" size="6"/> <data type="backgroundColor" size="5"/> <data type="endMarker" size="2"/> </headerData> <!-- Cumulative frame size summary. --> <frames totalSize="74091"> <frame name="_RTest_mx_managers_SystemManager" size="56409" frame="1"/> <frame name="RTest" size="17682" frame="2"/> </frames> <!-- Actionscript code and constant data. --> <actionScript totalSize="73608"> <abc name="frame1" size="56333" frame="1"/> <abc name="frame2" size="17275" frame="2"/> </actionScript> <!-- defineSprite. --> <sprites totalSize="19"> <sprite name="_RTest_Styles__embed_css_Assets_swf_mx_skins_cursor_BusyCursor_1134830057" size="19" frame="2"/> </sprites> <!-- defineShape/2/3/4. --> <shapes totalSize="261"> <shape size="261" frame="2"/> </shapes> <!-- Additional frame tags (symbolClass, exportAssets, showFrame, etc). --> <frameData totalSize="203"> <tag type="symbolClass" size="84" frame="2"/> <tag type="symbolClass" size="39" frame="1"/> <tag type="frameLabel" size="35" frame="1"/> <tag type="exportAssets" size="33" frame="2"/> <tag type="frameLabel" size="8" frame="2"/> <tag type="showFrame" size="2" frame="1"/> <tag type="showFrame" size="2" frame="2"/> </frameData> </swf> </report> Additional Implementation DetailsNot applicable. Prototype WorkA prototype exists and has been checked into the Flex 4.5 feature branch. The implementation will be modified as necessary to account for specification changes or related feedback. Compiler WorkA new *[TagEncoder]* derivative (*TagEncoderReporter*) was created which tallies all the relevant size data while the SWF tags are being emitted. A *SizeReport* instance is used to collect the statistics, and when requested, SizeReport::generate() is used internally to generate the requested XML report. Web Tier Compiler ImpactA new compiler flag is provided to enable generation of the size report (-size-report). Flex Feature DependenciesNot applicable. Backwards CompatibilityNot applicable. AccessibilityNot applicable. PerformanceNot applicable. GlobalizationNot applicable. LocalizationCompiler FeaturesNot applicable. Framework FeaturesNot applicable. Issues and RecommendationsNot applicable at this time. DocumentationNot applicable. QASuggested focus areas and test cases to consider (not exhaustive):
|
|
| You must be logged in to comment. |
|---|

Comments (2)
Aug 30, 2010
Lasse Moos says:
When I run the terminal command: mxmlc -size-report /Users/Lasse/Desktop/SDKTest...When I run the terminal command: mxmlc -size-report /Users/Lasse/Desktop/SDKTest.as, I get an error:
Error: a target file must be specified
It's probably a rookie mistake, but I can compile the same file just fine using: mxmlc /Users/Lasse/Desktop/SDKTest.as - so how do I specify the target file correctly?
Aug 31, 2010
Corey Lucier says:
I believe it's just like link report. Specify the name of the report file like:...I believe it's just like link report. Specify the name of the report file like:
mxmlc -size-report=report.xml SDKTest.as