Closed Bug 724608 Opened 13 years ago Closed 13 years ago

unable to serialize/deserialize custom class across workers

Categories

(Tamarin Graveyard :: Workers, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: dschaffe, Unassigned)

References

Details

Not able to pass a user written class with flash.net.registerClassAlias or Worker.registerClassAlias across workers. When the object gets passed back the object returns as Object and (result is Myclass) returns false. flash.net.registerClassAlias("Myclass",Myclass); var myclass:Myclass=new Myclass(); print(myclass is Myclass); // returns true promise=remote.echo(myclass); // call remote method to worker var result=promise.receive(); print(result is Myclass); // returns false I also tried with Worker.registerClassAllias and got the same results.
the full source for the example: amfbug.as: package { import flash.net.registerClassAlias; import flash.system.Promise; import flash.system.Worker; import flash.system.WorkerDomain; import flash.utils.ByteArray; public class workers3 { public function workers3() { if (Worker.current.isPrimordial()) { flash.net.registerClassAlias("Myclass",Myclass); //Worker.registerClassAlias("Myclass",Myclass); var worker:Worker=WorkerDomain.current.createWorkerFromPrimordial(); var remote:Promise=worker.start(); var myclass:Myclass=new Myclass(); myclass.value1=10; myclass.value2=3.14; myclass.value3=true; myclass.value4="hello"; trace("myclass: "+myclass); // test with ByteArray AMF, works ok var ba:ByteArray=new ByteArray(); ba.writeObject(myclass); ba.position=0; var result1:*=ba.readObject(); var myclass1:Myclass=result1 as Myclass; trace("myclass1: "+myclass1); // pass to a worker, does not work var promise:Promise=remote.async::workers3.async::echo(myclass1); var result2:*=promise.receive(); trace("myclass is Myclass: "+(result2 is Myclass)); var myclass2:Myclass=result2 as Myclass; trace("myclass2: "+myclass2); worker.stop(); } } public static function echo(o) { return o; } } public class Myclass { public function Myclass() { } public var value1:int=-1; public var value2:Number=-1.1; public var value3:Boolean=false; public var value4:String="default"; public function toString():String { return "[Myclass] "+value1+" "+value2+" "+value3+" "+value4; } } new workers3(); } $ java -jar asc.jar -import builtin.abc -d amfbug.as $ avmshell_s amfbug.abc myclass: [Myclass] 10 3.14 true hello myclass1: [Myclass] 10 3.14 true hello myclass is Myclass: false myclass2: null
Blocks: 695061
marking not a bug. The background worker must also call flash.net.registerClassAlias. the test works after moving flash.net.registerClassAlias out of the isPrimordial code.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.