Improve avm and tooling support for swf files

NEW
Unassigned

Status

10 years ago
8 years ago

People

(Reporter: lhansen, Unassigned)

Tracking

unspecified
Future
x86
Mac OS X
Bug Flags:
in-testsuite ?
flashplayer-qrb +
flashplayer-triage +

Details

Attachments

(1 attachment, 2 obsolete attachments)

(Reporter)

Description

10 years ago
swf files are well documented and handy archives containing stuff.  It ought to be possible for the avmshell to load a swf, notably in the case where the swf contains just a sequence of ABC fragments, and then execute those fragments in order.

We need:
 - a utility to stich ABC files together into a swf
 - a utility to dump a SWF (for debugging)
 - code in the avmshell to decode the swf
(Reporter)

Comment 1

10 years ago
Created attachment 360534 [details] [diff] [review]
swfmake, v1 - creates uncompressed or compressed swf from multiple abc files.  Goes into the utils/ directory.
Attachment #360534 - Flags: review?(edwsmith)

Comment 2

10 years ago
(In reply to comment #0)
>  - a utility to dump a SWF (for debugging)

abcdump knows how to read swf's (even compressed ones).  it doesn't do much with them except to dump the abc segments, but could do more, easily.

Updated

10 years ago
Attachment #360534 - Flags: review?(edwsmith) → review+

Comment 3

10 years ago
Comment on attachment 360534 [details] [diff] [review]
swfmake, v1 - creates uncompressed or compressed swf from multiple abc files.  Goes into the utils/ directory.

off the top of my head i dont remember the definition of the bits in the DoABC flags field, but its used to tell the VM whether to execute that abc's "entry point script" which is the last script.

suggestion, for sooner or later:
given N abc's, the swf should be written so the last one is marked to execute, and the middle ones are libs.  this matches the avmshell cmdline behavior.

marking R+ because we can improve incrementally and this has immediate use.
(Reporter)

Comment 4

10 years ago
Pushed swfmake.as.

Looking at abcdump, I consider the swf dumping issue resolved.  (I have a fancier program written in C but it's not necessary here.)

Will look into changes to avmshell next.

Re the flag bit, the spec says "Flags (UI32) A 32-bit flags value, which may
contain the following bits set: kDoAbcLazyInitializeFlag = 1: Indicates that the ABC block should not be executed immediately, but only parsed. A later finddef may cause its scripts to execute."

Comment 5

10 years ago
doesn't asc already build swfs? -swf flag,  I guess another abc utility could
also build swfs by inserting existing abcs into a swf.

I have been working on a utility to load swfs in the shell.  patch is here
https://bugzilla.mozilla.org/show_bug.cgi?id=476720

- decodes the swf tags (uses the code from abcdump/swfdump)
- dynamically loads the DoABC tag code
- any SymbolClass tag containing a string instantiates the class
- loads the avmglue.abc stubbed out glue code implementation so references to 
flash objects like Sprite,MovieClip are known

a simple example works like:
test1.as:
package {
    import flash.display.*;
    import flash.text.*;
    public class test1 extends Sprite {
        public function test1() {
            trace("constructor: start");
            var tf=new TextField();
            tf.text="test1";
            tf.width=200;
            tf.height=50;
            addChild(tf);
            trace("constructor: end");  
        }
    }
}

$ asc -import $PLAYERGLOBALABC -import GLOBALABC -swf test1,550,400 test1.as
$ $AVM playershell.abc -- test1.swf
** loadabcfile avmglue.abc
** parsing test1.swf
frame rate 12
frame count 1
size width=550 size height=400
Tag 69 FileAttributes
    size: 4
Tag 72 DoAbc
DoABC saving abc code as 0
    size: 631
Tag 76 SymbolClass
SymbolClass: count=1
SymbolClass: id=0 name=test1
    size: 10
Tag 1 ShowFrame
    size: 0
** loading blocks
** loading block 0 frame0
loading bytecode block frame0
** loading objects
** constructing test1
[object test1] Sprite constructor
constructor: start (from trace)
[object TextField] TextField.set text('test1')
[object TextField] DisplayObject.set width(200)
[object TextField] DisplayObject.set height(50)
[object test1] DisplayObjectContainer.addChild([object TextField]) parent=null
[object TextField] DisplayObject.set parent([object test1]) [object TextField]
constructor: end (from trace)
[object Stage] DisplayObjectContainer.addChild([object test1]) parent=null
[object test1] DisplayObject.set parent([object Stage]) [object test1]

Updated

10 years ago
Flags: in-testsuite?
Flags: flashplayer-triage+
Flags: flashplayer-qrb?

Comment 6

10 years ago
Created attachment 369887 [details] [diff] [review]
remove resources hashtable (vestigal code)

prerequisite for swf support; sticking lots of ScriptBuffers into this table causes problems, but the table is on the chopping block anyway, so this removes it.
Attachment #360534 - Attachment is obsolete: true
Attachment #369887 - Flags: review?(lhansen)

Comment 7

10 years ago
Created attachment 369888 [details] [diff] [review]
support uncompressed swfs

if input file starts with 'FWS' (any version), parse it as a swf.
- skips header
- each DoABC2 tag passed to handleActionBlock() or parseActionBlock() if the DoABC2 lazy bit is set.

supports swfs from swfmake, tested so far on esc (created main.swf and esc.swf)

todo:
- add swfmake step to esc makefile
- support compressed swfs
- better bounds checking
- put swf support code in a separate file (avmshell is dumping ground)

if any of these seem important before landing initial support, lmk
Attachment #369888 - Flags: review?(lhansen)
(Reporter)

Updated

10 years ago
Attachment #369887 - Flags: review?(lhansen) → review+
(Reporter)

Updated

10 years ago
Attachment #369888 - Flags: review?(lhansen) → review+

Comment 8

10 years ago
Comment on attachment 369887 [details] [diff] [review]
remove resources hashtable (vestigal code)

pushed http://hg.mozilla.org/tamarin-redux/rev/decc16fdc2c7

Updated

10 years ago
Attachment #369887 - Attachment is obsolete: true

Updated

9 years ago
Flags: flashplayer-qrb? → flashplayer-qrb+
Priority: -- → P3
(Reporter)

Comment 9

9 years ago
Keeping open because of the 'todo' list in comment #7.
Priority: P3 → --
Target Milestone: --- → Future

Updated

8 years ago
Summary: Make avmshell operate on swf files → Improve shell support for swf files

Updated

8 years ago
Component: Virtual Machine → Tools
QA Contact: vm → tools
Summary: Improve shell support for swf files → Improve avm and tooling support for swf files
You need to log in before you can comment on or make changes to this bug.