[webkit-dev] Callback function crashed in multiThread environment

石东海 shidonghai at gmail.com
Tue Apr 7 00:57:36 PDT 2009


Hi All,

We are developing some Mobile function related APIs for javascript users
through NPObject, everything works well expect for the callback events in
the multithreads environment. for example,

we would like to do some search operation in a new thread, and return the
search result in asynchronized way,
so, in our code, we define a JSObject *m_onMessageFound to store the user
defined funtion in setProperty operation.

*m_onMessageFound = KJS::Bindings::convertNPVariantToValue(exec, value,
root);*

when the new thread finished the search work, it will invoke the registered
function like below:

*m_onMessageFound->call(exec, NULL, args);*

The Javascript test code:

*Widget.xxx.onMessagesFound= function(var Msgs)
{
    **DEBUG("DisplayArea", "FindMessage", **"total matched "+Msgs.length**);
*
*}

var vLog = "";
function DEBUG(vDisp, sFlag, sMsg){
    if(vLog.length == 0){
        vLog = sFlag + ": " + sMsg;
    }
    else{
        vLog += "<br>" + sFlag + ": " + sMsg;
    }
    document.getElementById(vDisp).innerHTML = vLog;
}*

This will be crashed when *DEBUG()* was invoked, however, if we did not
start a new thread to search the result but invoke the callback in the same
thread, it won't crash.Or, if we remove "<br>" in the DEBUG() function, it
also won't crash.

Would anyone please provide some information on hwo to deal with these kinds
of problem.

Thanks a lot
-- 
Best regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090407/b22b29d6/attachment.html>


More information about the webkit-dev mailing list