[webkit-help] A Javascript-Objc bridge problem

Robert Vasvari vrobi at vasvari.com
Mon Dec 6 10:35:53 PST 2010

Here is the deal: under some circumstances, the javascript - objc
conversion done by objc_runtime.mm:convertValueToObjcObject()  fails.
Using the latest version of Webkit in gdb I traced
the problem back to convertValueToObjcObject(). In this function
findRootObject() is called:

RefPtr<RootObject> rootObject = findRootObject(exec->dynamicGlobalObject());
if (!rootObject)
       return nil;

 In my case this function returns NULL, therefore the next line simply
returns NULL, hence my objc object gets null as its property.

The JSValue-value variable passed into convertValueToObjcObject is
perfectly fine, it has the string data I want. Still,
because rootObject comes up NULL my string is discarded.

Questions: is it a legitimate situation that rootObject is NULL? Is it
possible that out ASP website comes up with legitimate javascript that
produces this situation? In that case I guess this is a bug in
WebCore. Turns out in this case rootObject is not needed, execState
and the JSValue are perfectly enough to set the value in the objc
object. I was able to get that working with a simple patch.

If rootObject being NULL is an abnormal situation, then it should be
flagged with a log message. Question is what javascript construct can
create such a situation. What is the workaround in javascript that
would help us avoid this error? The same javascript works fine in

We are working on an example javascript but has been unable to
complete that at this point. The app that produces the javascript for
us is really complex, we have not been able to isolate what causes our
problem on the javascript side.

I checked bugzilla, there are no bugs for this that I could find.

Any help is appreciated.


More information about the webkit-help mailing list