[Sugar-devel] [sugar-web] do webkit frames run on different threads?

Daniel Narvaez dwnarvaez at gmail.com
Thu Dec 19 16:43:13 EST 2013


On 19 December 2013 17:14, Code Raguet <iraguet at activitycentral.com> wrote:

>
> On Thu, Dec 19, 2013 at 12:28 PM, Daniel Narvaez <dwnarvaez at gmail.com>wrote:
>
>> Can you explain where multi thread would be an issue in our code? Why I'm
>> thinking perhaps simplistically is that we are already dealing with the
>> window.sugar stuff being available asyncronously.
>
> Yes, we dealt with this, already. But I didn't know that some browser may
> run frames simultaneously.
>
> Suppose the following scenario:
> * order of execution is not guaranteed
> * javascript from python runs on top frame
> * env.js runs on an iframe
> * different frames may run simultneously
>
> js from python:
>
>> var environment = %s;              <--- phase 1
>
> if (window.sugar === undefined) {
>>   window.sugar = {};
>> }
>> window.sugar.environment = environment;  <--- phase 2
>
>
> from getEnvironment:
>
>> if (window.top.sugar) {
>
>   sugar = window.top.sugar;
>> } else {
>>   sugar = {};                      <--- phase 1
>>   window.top.sugar = sugar;              <--- phase 2
>> }
>
>
This code in getEnvironment is wrong, just a thinko by me.

We should not set window.top.sugar = {} from the javascript side. Instead
we should if isStandalone callback({}).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20131219/8b4b6722/attachment.html>


More information about the Sugar-devel mailing list