tidev / ti.worker

Use Multi-Threading / Worker Threads in Appcelerator Titanium.
Other
96 stars 27 forks source link

Crash #5

Closed allenhartwig closed 7 years ago

allenhartwig commented 12 years ago

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?

allenhartwig commented 12 years ago

From the log:

Thread 10 name:  KrollContext<kroll$2>
Thread 10 Crashed:
0   libobjc.A.dylib                 0x35125f7e objc_msgSend + 22
1   Here On Biz                     0x002259f2 -[TiWorkerSelfProxy postMessage:] (TiWorkerProxy.m:39)
2   Here On Biz                     0x0003b3e0 -[KrollMethod call:] (KrollMethod.m:262)
3   Here On Biz                     0x0003a5da KrollCallAsFunction (KrollMethod.m:51)
4   Here On Biz                     0x001856e4 TI::TiCallbackObject<TI::TiObjectWithGlobalObject>::call(TI::TiExcState*) (TiCallbackObjectFunctions.h:397)
5   Here On Biz                     0x001a9878 TI::Interpreter::privateExecute(TI::Interpreter::ExecutionFlag, TI::RegisterFile*, TI::TiExcState*) (Interpreter.cpp:4055)
6   Here On Biz                     0x001ad33c TI::Interpreter::executeCall(TI::TiExcState*, TI::TiObject*, TI::CallType, TI::CallData const&, TI::TiValue, TI::ArgList const&) (Interpreter.cpp:949)
7   Here On Biz                     0x001d4b02 TI::call(TI::TiExcState*, TI::TiValue, TI::CallType, TI::CallData const&, TI::TiValue, TI::ArgList const&) (CallData.cpp:45)
8   Here On Biz                     0x00183508 TiObjectCallAsFunction (TiObjectRef.cpp:449)
9   Here On Biz                     0x00041a26 -[KrollTimer invokeWithCondition:] (KrollTimer.m:68)
10  CoreFoundation                  0x373803f6 -[NSObject performSelector:withObject:withObject:] + 46
11  Here On Biz                     0x000343f0 -[KrollInvocation invoke:] (KrollContext.mm:104)
12  Here On Biz                     0x00035b7c -[KrollContext invoke:] (KrollContext.mm:911)
13  Here On Biz                     0x000370e2 -[KrollContext main] (KrollContext.mm:1252)
14  Foundation                      0x37c0ca7a -[NSThread main] + 66
15  Foundation                      0x37ca058a __NSThread__main__ + 1042
16  libsystem_c.dylib               0x33c9b72e _pthread_start + 314
17  libsystem_c.dylib               0x33c9b5e8 thread_start + 0
allenhartwig commented 12 years ago

It's an issue with 2.1+ SDK. Fix is a big TBD right now. I've been working closely with the Appcelerator team on.

allenhartwig commented 12 years ago

Here is the update I got today: "As of now, Ti.Worker has been fixed to a point that it is usable on the 2.0.x SDK. Engineering has explained that there are significant hurdles to implementing Ti.Worker on 2.1.X or higher, the current fix has not had any testing, and it is a one off fix that is not necessarily going to work for everyone ... "

ghost commented 12 years ago

Ok, I did a clean installation so I have the last Titanium Studio also the last SDK... I'll try with 2.0.2. Thanks for the info!

ghost commented 12 years ago

Working now! Thanks again!

jbeuckm commented 11 years ago

Any news for SDK 3+ ?

allenhartwig commented 11 years ago

I wouldn't expect any further development on this module. However I've been able to code my way around needing it. What's your use case?

jbeuckm commented 11 years ago

I just need to do something off the UI thread. Is there a Titanium way to do that?

allenhartwig commented 11 years ago

No. You just have the one thread. However, I wrote my own loop manager so my background processes don't tie up the ui thread and effect user interaction performance.

jbeuckm commented 11 years ago

I want to do some larger operations that aren't in loops. Maybe I can create an off-screen webview and do it with web workers.

knotsocial commented 11 years ago

@jbeuckm Any luck getting web workers on an off-screen webview to work? I've got the exact same situation, have a long running operation I need to hand off to a background thread and still have Ti.App.fireEvent be responsive (it seems to block currently)

knotsocial commented 11 years ago

Just a follow up to pass on that yes using web worker with a non-visible/non-focusable WebView works, and the Ti.App events don't appear to block while the worker is busy - unlike the createWindow({ url:"some.js" }) technique which as far as I can tell isn't multithreaded at all. Hopefully this will be of some help to people who came here looking for a working ti.worker module (which seems to be broken since iOS6)