[RFC] Single threaded JSRuntime in Firefox 10

Deepak Bhole dbhole at redhat.com
Thu Feb 16 11:51:17 PST 2012


* Thomas Meyer <thomas at m3y3r.de> [2012-02-03 20:20]:
> Hello,
> 
> please have a look at this first patch that fixes the sendMember() and
> eval() methods for firefox 10:
> 

Hi Thomas,

I don't think these will actually fix the issue. The issue is
intermittent, so your fixes are probably just reducing the frequency.

The problem is the use of the browser_function.* functions from non-JS
threads.

I am working on a patch to resolve it. However your patch is still a
good re-factor and I think it would make a good addition on top :)

I'll reply back after I've posted the fix.

Thanks,
Deepak

> # HG changeset patch
> # User thomas
> # Date 1328317526 -3600
> # Node ID 6962b636cfdaeef1efa884bcd2207a1360baa978
> # Parent  528e354ff46919a758c8977978053fbb816ffebc
> Fix eval() and sendMember() for the new single thread JSRuntime in Firefox 10. See also:
> - https://bugzilla.mozilla.org/show_bug.cgi?id=704249
> - http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=820
> - http://groups.google.com/group/mozilla.dev.tech.js-engine/msg/ae5f22f39e4fd150
> 
> diff -r 528e354ff469 -r 6962b636cfda plugin/icedteanp/IcedTeaPluginRequestProcessor.cc
> --- a/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc	Thu Feb 02 16:15:27 2012 -0500
> +++ b/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc	Sat Feb 04 02:05:26 2012 +0100
> @@ -241,19 +241,9 @@
>  
>      IcedTeaPluginUtilities::callAndWaitForResult(instance, &_eval, &thread_data);
>  
> -    NPVariant* result_variant = (NPVariant*) IcedTeaPluginUtilities::stringToJSID(thread_data.result);
> -    std::string result_variant_jniid = std::string();
> -    if (result_variant)
> -    {
> -        createJavaObjectFromVariant(instance, *result_variant, &result_variant_jniid);
> -    } else
> -    {
> -        result_variant_jniid = "0";
> -    }
> -
>      IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &response);
>      response += " JavaScriptEval ";
> -    response += result_variant_jniid;
> +    response += thread_data.result;
>  
>      plugin_to_java_bus->post(response.c_str());
>  }
> @@ -522,7 +512,7 @@
>      /** Request data from Java if necessary **/
>      if (*(message_parts->at(4)) == "GetSlot")
>      {
> -        member_identifier = browser_functions.getintidentifier(atoi(member_id.c_str()));
> +    	//member_id = ;
>      } else
>      {
>          // make a new request for getString, to get the name of the identifier
> @@ -535,7 +525,7 @@
>              //goto cleanup;
>          }
>  
> -        member_identifier = browser_functions.getstringidentifier(java_result->return_string->c_str());
> +        member_id = *java_result->return_string;
>      }
>  
>      AsyncCallThreadData thread_data = AsyncCallThreadData();
> @@ -551,16 +541,10 @@
>  
>      thread_data.parameters.push_back(instance);
>      thread_data.parameters.push_back(NPVARIANT_TO_OBJECT(*parent_ptr));
> -    thread_data.parameters.push_back(&member_identifier);
> +    thread_data.parameters.push_back(&member_id);
>  
>      IcedTeaPluginUtilities::callAndWaitForResult(instance, &_getMember, &thread_data);
>  
> -    PLUGIN_DEBUG("Member PTR after internal request: %s\n", thread_data.result.c_str());
> -
> -    member_ptr = (NPVariant*) IcedTeaPluginUtilities::stringToJSID(thread_data.result);
> -
> -    createJavaObjectFromVariant(instance, *member_ptr, &result_id);
> -
>      IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &response);
>      if (*(message_parts->at(4)) == "GetSlot")
>      {
> @@ -568,7 +552,7 @@
>      } else {
>          response.append(" JavaScriptGetMember ");
>      }
> -    response.append(result_id.c_str());
> +    response.append(thread_data.result);
>      plugin_to_java_bus->post(response.c_str());
>  }
>  
> @@ -797,23 +781,27 @@
>  
>      instance = (NPP) parameters.at(0);
>      parent_ptr = (NPObject*) parameters.at(1);
> -    NPIdentifier* member_identifier = (NPIdentifier*) parameters.at(2);
> +    std::string*  member_id = (std::string*) parameters.at(2);
> +    NPIdentifier member_identifier;
> +
> +    member_identifier = browser_functions.getintidentifier(atoi(member_id->c_str()));
>  
>      // Get the NPVariant corresponding to this member
> -    PLUGIN_DEBUG("Looking for %p %p %p (%s)\n", instance, parent_ptr, member_identifier, browser_functions.utf8fromidentifier(*member_identifier));
> +    PLUGIN_DEBUG("Looking for %p %p %p (%s)\n", instance, parent_ptr, member_identifier, browser_functions.utf8fromidentifier(member_identifier));
>  
> -    if (!browser_functions.hasproperty(instance, parent_ptr, *member_identifier))
> +    if (!browser_functions.hasproperty(instance, parent_ptr, member_identifier))
>      {
> -        printf("%s not found!\n", browser_functions.utf8fromidentifier(*member_identifier));
> +        printf("%s not found!\n", browser_functions.utf8fromidentifier(member_identifier));
>      }
> -    ((AsyncCallThreadData*) data)->call_successful = browser_functions.getproperty(instance, parent_ptr, *member_identifier, member_ptr);
> +    ((AsyncCallThreadData*) data)->call_successful = browser_functions.getproperty(instance, parent_ptr, member_identifier, member_ptr);
>  
>      IcedTeaPluginUtilities::printNPVariant(*member_ptr);
>  
>      if (((AsyncCallThreadData*) data)->call_successful)
>      {
> -        IcedTeaPluginUtilities::JSIDToString(member_ptr, &member_ptr_str);
> +        createJavaObjectFromVariant(instance, *member_ptr, &member_ptr_str);
>          ((AsyncCallThreadData*) data)->result.append(member_ptr_str);
> +
>      }
>      ((AsyncCallThreadData*) data)->result_ready = true;
>  
> @@ -831,8 +819,8 @@
>      std::string* script_str;
>      NPIdentifier script_identifier;
>      NPString script = NPString();
> -    NPVariant* eval_result = new NPVariant();
> -    std::string eval_result_ptr_str = std::string();
> +    NPVariant* eval_variant = new NPVariant();
> +    std::string eval_variant_str = std::string();
>  
>      PLUGIN_DEBUG("_eval called\n");
>  
> @@ -854,13 +842,19 @@
>      PLUGIN_DEBUG("Evaluating: %s\n", script.UTF8Characters);
>  #endif
>  
> -    ((AsyncCallThreadData*) data)->call_successful = browser_functions.evaluate(instance, window_ptr, &script, eval_result);
> -    IcedTeaPluginUtilities::printNPVariant(*eval_result);
> +    ((AsyncCallThreadData*) data)->call_successful = browser_functions.evaluate(instance, window_ptr, &script, eval_variant);
> +    IcedTeaPluginUtilities::printNPVariant(*eval_variant);
>  
>      if (((AsyncCallThreadData*) data)->call_successful)
>      {
> -        IcedTeaPluginUtilities::JSIDToString(eval_result, &eval_result_ptr_str);
> -        ((AsyncCallThreadData*) data)->result.append(eval_result_ptr_str);
> +        if (eval_variant)
> +        {
> +            createJavaObjectFromVariant(instance, *eval_variant, &eval_variant_str);
> +        } else
> +        {
> +            eval_variant_str = "0";
> +        }
> +        ((AsyncCallThreadData*) data)->result.append(eval_variant_str);
>      }
>      ((AsyncCallThreadData*) data)->result_ready = true;
>  
> 
> 



More information about the distro-pkg-dev mailing list