tidev / ti.worker Goto Github PK
View Code? Open in Web Editor NEWUse Multi-Threading / Worker Threads in Appcelerator Titanium.
License: Other
Use Multi-Threading / Worker Threads in Appcelerator Titanium.
License: Other
I found a problem after repeating my background process several times during a normal use. (The user click on a ListView, the bg process starts/ends, a new window is open)
The module gets stuck right after
[_bridge evalJSWithoutResult:@"TiWorkerStart__();"];
in the booted
method:
- (void)booted:(id)bridge
{
// this callback is called when the thread is up and running
dispatch_async(_serialQueue, ^{
_booted = YES;
NSLog(@"[INFO] Worker %@ (0x%X) is running", [_selfProxy url], self);
[_selfProxy setExecutionContext:_bridge];
[[NSFileManager defaultManager] removeItemAtPath:_tempFile error:nil];
});
// start our JS processing
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[_bridge evalJSWithoutResult:@"TiWorkerStart__();"]; // STUCK HERE
});
}
usually the postMessage
method is what happens after, but not in some cases.
If you attempt to load a worker from a bad source location, it doesn't give any indication or error.
I am unable to log to the console within the worker file. Ti.API.info
throws a parse error.
Does the Android implementation of ti.worker still run code on UI thread ?
Just fyi... I was following the example but it wasn't working... but when I did a setTimeout() with 1 millisecond for posting to the task, it worked.
Thanks btw -- this is great and what I've been waiting for for Titanium!
I am getting a crash on the following code when posting data back from the worker.
-(void)postMessage:(id)msg
{
ENSURE_SINGLE_ARG(msg,NSObject);
// this is from the worker, posting back to the creator
NSDictionary *dict = [NSDictionary dictionaryWithObject:msg forKey:@"data"];
TiWorkerProxy *proxy = (TiWorkerProxy*)_parent;
[proxy fireMessageEvent:dict];
}
Is there a limit to the size of data that can be sent back?
works fine on ios<6
on 6 - SDK 2.1.3
KrollBridge.mm line 598
[self evalFile:[url path] callback:self selector:@selector(booted)];
url is nil: (supposed ti be the wrapped javascript) ...
When there is a syntax error in the worker file, the debug message in the console provides an incorrect/obfuscated source file.
Eg:
sourceURL = "file://localhost/var/folders/jb/b8vsmqzx00ng22t1383j_qfr0000gn/T/5694";
I have a problem with large database sincronization beacouse it's blocking user interface on iOs phones.
So it is posibble to add background task support to iOS so the database operations dont block the UI.
Just wondering if there was an android equivalent to this module.
Many thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.