Comments (6)
We are currently using MessageChannel
mechanism for communicating between workers. that means, you can send String or Numbers between the threads. we will add shareable properties in future versions.
the easy solution you have right now is to serialize your Bitmap into a String mabe by using Base64 standards or something similar. and send the String to the worker. Then generate your BitmapData back from the incoming String.
from easyas-worker.
to know better about what parameters you can send with the current mechanism, read this: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/MessageChannel.html#send%28%29
The object passed to the arg parameter can be almost any object. Other than the exceptions noted below, any object that is passed to the arg parameter is not passed by reference. Any changes made to the object in one worker after send() is called are not carried over to the other worker. The object is copied by serializing it to AMF3 format and deserializing it into a new object in the receiving worker when receive() is called. For this reason, any object that can't be serialized in AMF3 format, including display objects, can't be passed to the arg parameter. In order for a custom class to be passed properly, the class definition must be registered using the flash.net.registerClassAlias() function or [RemoteClass] metadata. With either technique the same alias must be used for both worker's versions of the class.
As mentioned in the documents, you can send shareable byteArrays using this method. (we have not tested this yet)
from easyas-worker.
Thank you for your answer. I was afraid I couldn't use BitmapData as parameter.
My original thought was to use the worker to serialize the BitmapData into a String using Base64 and then upload it to server because it uses lots of resources on mobile and the UI freezes during the process. Asynchronous encoding did the job instead of the worker.
from easyas-worker.
be aware that shareable byteArray have been disabled since flash/air version 30.x.x
to protect users from the spectre meltdown CPU security holes
from easyas-worker.
What do you suggest as shareable byteArray have been disabled.. Do you have a nice solution to pass bitmapdatas to worker without having to fully encode it in Base64? I mean I have huge bitmaps to handle, this process could kill the performances...
from easyas-worker.
the only way for now is to use MessageChannel...
from easyas-worker.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easyas-worker.