claus / as3swf

Low level Actionscript 3 library to parse, create, modify and publish SWF files.
MIT License
526 stars 127 forks source link

https://github.com/doublefx/easyWorker #34

Closed doublefx closed 10 years ago

doublefx commented 10 years ago

Just to thank you very much and inform you that I use your lib in my project, that's an awesome lib, thanks again !

makc commented 10 years ago

All aboard PR train bandwagon, remember this thing? Calling @bortsen, jump on :train: :train: :train: choo choo!

makc commented 10 years ago

Btw @doublefx this part

I use the very well done as3-commons-reflect and as3swf libs to reflect and emit the Worker and its dependencies

I mean dependencies part, sounds interesting. Maybe I could borrow some code there :)

doublefx commented 10 years ago

hehe, yes, I remember the @borsten work but unfortunately didn't work for my use cases, the reason why I did that. It's up to you to use and borrow what you want indeed ;-)

claus commented 10 years ago

Reminder: Flash is dead.

/ducks/

makc commented 10 years ago

Is that official mozilla statement?

claus commented 10 years ago

Official Wahlers PSA. Please contact my PR department for further inquiries.

doublefx commented 10 years ago

Hi guys, I take the opportunity this ticket is still open to ask you about a bug I'm facing, I can't debug it because it happens only on releases (-debug=false), so, I guess it should be something obvious but I still didn't get it, this is the stack trace:

TypeError: Error #1009: Cannot access a property or method of a null object reference. at com.codeazur.as3swf::SWFTimelineContainer/publishTag() at com.codeazur.as3swf::SWFTimelineContainer/publishTags() at com.codeazur.as3swf::SWF/publish() at com.doublefx.as3.thread.util::WorkerFactory$/getWorkerFromClass() at com.doublefx.as3.thread::Thread() at Main/windowCompleteHandler() at Main/___Main_WindowedApplication1_windowComplete() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent() at spark.components::WindowedApplication/enterFrameHandler()

And how I construct the swf https://github.com/doublefx/easyWorker/blob/master/API/src/main/flex/com/doublefx/as3/thread/util/WorkerFactory.as

Any advices would be very appreciated.

Thanks, Fred.

makc commented 10 years ago

you probably can debug it if you place a bunch of trace()-s in with line numbers in publishTag/s methods and then use omit-trace-statements=false (mxmlc). I have never done it, might not work - use some other logging method then.

claus commented 10 years ago

Does mxmlc compile classes into separate DoABCs in release builds?

makc commented 10 years ago

@claus there's optimize=false that can probably do it. do you think his code fails when there is just 1 tag?

claus commented 10 years ago

Not sure (at all, it's just a wild guess), but that worker thingie seems to expect classes to be in separate DoABCs.

doublefx commented 10 years ago

Thanks for the advices guys, I found it:

That's because of the -optimize=true set when -debug=false, doing optimize=false solve the problem but still, I don't think the users will like this, any way I can fix it differently ?

The runtime error wasn't because of it but because of " SWFTimelineContainer:308: trace("WARNING: publish error: " + e.message + " (tag: " + tag.name + ")");"

tag and rawTag are null when optimize=true

doublefx commented 10 years ago

but that worker thingie seems to expect classes to be in separate DoABCs.

Humm , not sure I've got that one, can you explain ?

doublefx commented 10 years ago

Also, I noticed I've got some "FATAL: publish error: No raw tag fallback" still from the same function when -debug=true and optimize=false, nothing visible I've been able to noticed but I wonder if at time it will shows side effects

claus commented 10 years ago

Not sure where to start.. You give WorkerFactory.getWorkerFromClass a clazz parameter, which is your worker class. It then scans all tags in the SWF for DoABC tags (those contain the ActionScript byte code) and checks if one of them has a name equal to your clazz. It then takes that tag (amongst others), puts it into a new SWF and publishes that SWF in memory so you can use that as your worker.

This obviously only works when the compiler compiles all your classes into separate DoABC tags. If -optimize=true, the compiler compiles all of your classes into one big DoABC tag, so WorkerFactory.getWorkerFromClass can't find your worker class. That's why you have to compile with -optimize-false, and i'm afraid there's little you can do about it.

Now, that runtime error you get is probably (again, wild guess) because you still invoke WorkerFactory.getWorkerFromClass with the debug parameter set to true. This code: https://github.com/doublefx/easyWorker/blob/master/API/src/main/flex/com/doublefx/as3/thread/util/WorkerFactory.as#L117 should probably be something like if (debug && debugTag) swf.tags.push(debugTag); to prevent that. Again, not tested, so it might be something else.

Finally, that FATAL publish error you get is just a consequence of a tag being null, because as the SWF is created dynamically, there are no raw tags to fall back to.

doublefx commented 10 years ago

Thanks for the explanation, didn't know it was only one DoABC tag when optimized even if I should have guessed it :P and I don't want to copy the entire swf in memory, so, it will be to the users to decide if they still want to use my lib setting optimize=false even for releases.

should probably be something like if (debug && debugTag) swf.tags.push(debugTag); to prevent that.

You was right.

Thanks again.