Re: [IndexedDB] Granting storage quotas

On Tue, Apr 13, 2010 at 4:53 PM, Joćo Eiras <joaoe@opera.com> wrote:

> On Tue, 13 Apr 2010 12:09:14 +0200, Mark Seaborn <mseaborn@chromium.org>
> wrote:
>
>  Is there any plan for involving the user in storage allocation decisions
>> for
>> IndexedDB? [1]
>>
>> For comparison, the WebStorage API [2] doesn't have any special support
>> for
>> the user to make allocation choices.  My understanding is that browsers
>> have
>> a fixed storage limit per origin -- in Chromium, 5Mb per origin.  The
>> problem with this model is that it is both too permissive and too
>> restrictive.
>>
>
> Not really. The user agent can ask for quota from the user when the limit
> is being hit without the webpage even having to worry about it. Opera 10.50
> does that.
>

I tried this out in Opera with a script that doubles the amount of storage
it uses on each reload [1].  I got a dialog saying:

    "Web Storage Quota

    foo.com wants to store data on your computer, but needs more space.

    Current limit: 2.7 MB

    Requested limit: 5.4 MB
    [this is a dropdown, also containing:
    8.1 MB
    10.7 MB
    21.4 MB
    42.7 MB
    Unlimited]

    [Allow] [Reject]"

This is still too restrictive because:

1) It doesn't allow a web app to ask for a storage allocation up front,
before it starts to consume the storage.
2) In Opera, the quota can only be increased in multiples of about 15, so it
takes three prompts to get up into the range of gigabytes.
3) The web app can't choose when the question is put to the user.
4) The web app doesn't know how much storage has been allocated, so it
doesn't know when a question will be asked.
5) In Opera, if the user chooses "Reject", they don't get prompted again.
This means that asking the user at an appropriate time is important for the
continued functioning of the web app.  Prompting the user at the wrong time
will interrupt them with a page-modal dialog which they might want to get
rid of with "Reject", which would potentially break the web app by leaving
it unable to get more storage.

The workaround for (1) is to write junk data into local storage in an
attempt to force the browser to produce a prompt.  This is obviously
inefficient.  Also, this strategy is dependent on knowing what the initial
quota is, but because of (4), a web app would have to guess based on
knowledge of particular browsers' policies.

(2) is easily addressed by providing an editable field and not just a
dropdown.

(1) and (3) would be addressed by adding a requestQuota() interface as I
suggested.

For (5), I couldn't find any options in the UI for resetting the
prompt/reject state so that Opera would prompt again.  "Delete Private Data"
-> "Delete Web storage databases" did not reset the prompt/reject state.
However, by searching I found that "opera:webstorage" provides a page for
granting larger quotas and resetting the prompt/reject state.

(5) could be addressed by using a non-modal info bar, or by addressing (3).

I don't mean to pick on Opera, by the way.  I think it's positive that it
does allow the quota to be increased.

Regards,
Mark


[1] Here's the page I used to test this:

<p>
  You have viewed this page
  <span id="count">an untold number of</span>
  time(s).
</p>
<p>
  Space consumed: <span id="bytes"></span>
</p>
<script>
  try {
    if (!localStorage.pageLoadCount) {
      localStorage.pageLoadCount = 0;
      localStorage.data = "x";
    }
    localStorage.pageLoadCount = parseInt(localStorage.pageLoadCount) + 1;
    document.getElementById('count').textContent =
localStorage.pageLoadCount;
    var data = localStorage.data;
    data = data + data;
    localStorage.data = data;
    document.getElementById('bytes').textContent = data.length + " chars";
  }
  catch (exn) {
    document.getElementById('bytes').textContent = exn;
  }
</script>

Received on Tuesday, 20 April 2010 11:12:03 UTC