Re: [chromium-html5] LocalStorage inside Worker

On Thu, Jan 27, 2011 at 12:39 AM, Felix Halim <felix.halim@gmail.com> wrote:

> 2011/1/7 Jonas Sicking <jonas@sicking.cc>:
> > On Thu, Jan 6, 2011 at 7:14 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> >> On 1/6/11 5:25 PM, Joćo Eiras wrote:
> >>>
> >>> Not different from two different tabs/windows running the same code.
> >>
> >> In which current browsers do same-origin tabs/windows end up
> interleaving
> >> their JS (that is, one runs JS before the other has returned to the
> event
> >> loop)?
> >
> > I'm fairly sure it happens both in Chrome and IE. One way it can happen
> is:
> >
> > Tab 1 opens with a page from site A
> > Tab 2 opens with a page from site B
> > The page in tab 2 contains an iframe with a page from site A.
> >
> > But I'm not even sure that Chrome and IE makes an effort to use the
> > same process if you open two tabs for the same site.
>
> It seemed that Chrome doesn't interleave the JS when the same page is
> opened in multiple tabs.
>
> Try running this script in multiple tabs and monitor the console output:
>
> http://felix-halim.net/interleave.html
>
> In Chrome console log, you will see many "FAIL", but not in Firefox.
>
> So does this mean localStorage in Chrome is broken? or this is an
> intended behavior?
>

Although the updates to localStorage are "interleaved", the two tabs are
not: both are running in different processess/event-loops.  I.e. they run
parallel.  i.e. localStorage (and cookies) don't support "run to
completion".

We don't implement the storage mutex as specced because it'd severely limit
this concurrency.  If you search the archives, you'll find a lot of
discussions about this.

If this is a problem for you, then I suggest you look at WebSQLDatabase or
(soon) IndexedDB.

J

Received on Thursday, 27 January 2011 19:02:28 UTC