[webkit-help] JavascriptCore: functions executing on a native timer

Spencer Kohan spencerkohan at gmail.com
Mon Feb 18 06:15:45 PST 2013


So it looks like it was a problem with the context.  I tries adding a
JSValueProtect and that didn't help, and then I switched to calling the
function using the global context instead of the context passed to the
'setTickFunction' callback and that fixed the problem.

So it's working, which is great, but I still don't understand what the
issue was exactly.  Is there any documentation on how contexts work, and/or
rules of thumb on how to use them safely?

-Spencer


On Mon, Feb 18, 2013 at 2:20 AM, Arunprasad Rajkumar <ararunprasad at gmail.com
> wrote:

> May be reference count issue? Try to increase the reference count of the
> cached function using JSValueProtect. While cleanup the cached object
> use JSValueUnprotect.
>
> On 18 February 2013 11:18, Spencer Kohan <spencerkohan at gmail.com> wrote:
>
>> I'm working on a simple application where a few JS functions are cached
>> during setup and then called repeatedly on a timer.  I'm getting a failed
>> assertion when the cached script is called, and I don't know how to debug
>> it.
>>
>> So my C application looks something like this:
>>
>>     static JSContextRef cachedFunctionContext;
>>
>>     static JSObjectRef cachedFunction;
>>
>>     //this callback caches the 'tick' function defined in the setup script
>>
>>     JSValueRef setTickFunctionCallback(JSContextRef ctx, JSObjectRef
>> function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef
>> arguments[], JSValueRef *exception){
>>
>>         cachedFunction = arguments[0];
>>
>>         cachedFunctionContext = ctx;
>>
>>         JSValueProtect(ctx, cachedFunction);
>>
>>         return JSValueMakeNull(ctx);
>>
>>     }
>>
>>     //this function runs the setup script
>>
>>     void setup(const char* setupScript){
>>
>>         //setup context and native callbacks
>>
>>         JSEvaluateScript(context, scriptJS, NULL, NULL, 0, NULL);
>>
>>     }
>>
>>     //this function is called on a timer
>>
>>     void tick(){
>>
>>          JSObjectCallAsFunction(cachedFunctionContext, cachedFunction,
>> NULL, 0, NULL, NULL);
>>
>>     }
>>
>> And my setup script looks something like this:
>>
>>     var setup = function() {
>>
>>         setTickFunction(function(){
>>
>>             //do something
>>
>>         });
>>
>>     }
>>
>>     setup();
>>
>> But during execution, I get this assertion failure I don't know how to
>> interpret:
>>
>> *ASSERTION FAILED: callFrame->frameExtent() <= oldEnd || callFrame ==
>> callFrame->scopeChain()->globalObject->globalExec()*
>>
>> Any insight into what I might be doing wrong would be greatly appreciated.
>>
>> _______________________________________________
>> webkit-help mailing list
>> webkit-help at lists.webkit.org
>> https://lists.webkit.org/mailman/listinfo/webkit-help
>>
>>
>
>
> --
> *Arunprasad Rajkumar*
> http://in.linkedin.com/in/ararunprasad
>



-- 
Spencer Kohan
cell: 216 288 8258
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20130218/541c3595/attachment.html>


More information about the webkit-help mailing list