Bug 149585

Summary: Heavy LocalStorage use can cause page to freeze
Product: WebKit Reporter: Nolan Lawson <nolan>
Component: WebKit2Assignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: andersca, ap, beidson, medikoo+webkit.org, nekr.fabula
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Mac   
OS: OS X 10.10   
Attachments:
Description Flags
Same HTML page as the live demo none

Description Nolan Lawson 2015-09-27 07:11:42 PDT
Created attachment 261987 [details]
Same HTML page as the live demo

Doing many successive insertions into LocalStorage can cause the page to freeze, with an eternal spinning beach ball and no ability to interact with the page.

I've got a live demo to repro: http://nolanlawson.github.io/database-comparison/

Steps:
1. Choose "LocalStorage"
2. Choose 100000
3. Click "insert docs"
4. Notice that the page is frozen, with a perma-beachball

This bug cannot be reproduced in Edge, Firefox, or Chrome, but I note that Safari is the only browser out of the four to *not* block DOM rendering while LocalStorage operations are ongoing. :)

I'm testing WebKit Nightly, Version 8.0.8 (10600.8.9, r190266)
Comment 1 Alexey Proskuryakov 2015-09-28 20:55:04 PDT
I feel like this may have been reported before, but I cannot find it now.
Comment 2 Brady Eidson 2015-09-29 12:46:46 PDT
This bug is not terribly surprisingly.

That it doesn't happen in other browsers *is* kind of surprising; LocalStorage is a synchronous API, so it's very easy to abuse.

Can you get a spin dump while this is happening?
Comment 3 Anders Carlsson 2015-09-29 12:50:16 PDT
(In reply to comment #2)
> LocalStorage is a synchronous API ...

This is not entirely true. The only synchronous operation is getting the initial values from the UI process.
Comment 4 Brady Eidson 2015-09-29 13:15:23 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > LocalStorage is a synchronous API ...
> 
> This is not entirely true. The only synchronous operation is getting the
> initial values from the UI process.

I wasn't talking about the way we've implemented I/O, but rather how it operates from script's perspective.
Comment 5 Arthur 2015-10-05 02:48:33 PDT
Seems like only Safari has asynchronous localStorage behind the scene. Indeed surprisingly that other browsers do all the ops in sync way, naturally they cannot have async/race bugs here. Anyway, thanks for doing localStorage async!
Comment 6 Brady Eidson 2015-10-15 14:09:34 PDT
I still don't have time to dig in to this myself at the moment, but would find a spindump very interesting. That would give the appropriate hints on how to solve this.
Comment 7 Mariusz Nowak 2016-11-26 10:02:58 PST
It seems it's a duplicate of https://bugs.webkit.org/show_bug.cgi?id=129896
Comment 8 Alexey Proskuryakov 2016-12-14 09:27:00 PST
Could you please verify with the latest nightly?

https://nightly.webkit.org

*** This bug has been marked as a duplicate of bug 165622 ***