alcosholik at gmail.com
Sat Dec 7 04:04:21 PST 2013
My question in short: is it necessary to call JSValueProtect right after
object/value creation in C++? I don't know the semantics of the GC, but I'm
assuming that almost any call to a JSC function that takes a context may
run a garbage collection cycle. Therefore, if I'm not immediately returning
the created object, it might get cleaned up prematurely.
Could you share some advice on the proper usage of JSValueProtect and on
keeping objects from going away unexpectedly?
Some background info:
I'm experiencing intermittent bugs in my C++ to JS binding, I'm only
guessing that GC might be related to that. What I'm seeing is that objects
created in C++ are occasionally missing their properties.
In one example, there is a single code path from C++ to JS that takes a
native object and creates a corresponding JS object using appropriate
JSClassRef (which is prepopulated with some methods).
In the JS land, there is always the same method called on the object (the
one that has just been created in C++ land with the appropriate
JSClassRef). 9 out of 10 times it works fine, but every once in a while I
get an exception "undefined is not a function", i.e. the method on the
object is missing.
The way I'm linking native and JS objects is by keeping an associative
array of their pointers, so that I can get back to the native object in the
C++ callback called from JS.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev