<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>25223</bug_id>
          
          <creation_ts>2014-04-01 20:39:10 +0000</creation_ts>
          <short_desc>IDB exposes GC behavior</short_desc>
          <delta_ts>2015-08-10 20:01:57 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>Indexed Database API</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Olli Pettay">bugs</reporter>
          <assigned_to name="This bug has no owner yet - up for the taking">dave.null</assigned_to>
          <cc>annevk</cc>
    
    <cc>jonas</cc>
    
    <cc>jsbell</cc>
    
    <cc>mike</cc>
    
    <cc>public-webapps</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>103245</commentid>
    <comment_count>0</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2014-04-01 20:39:10 +0000</bug_when>
    <thetext>http://logs.glob.uno/?c=freenode%23whatwg&amp;s=1%20Apr%202014&amp;e=1%20Apr%202014#c866471</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103289</commentid>
    <comment_count>1</comment_count>
    <who name="Joshua Bell">jsbell</who>
    <bug_when>2014-04-02 19:06:19 +0000</bug_when>
    <thetext>Current spec text:

&quot;The connection can be closed through several means. If the connection is GCed or execution context where the connection is created is destroyed (for example due to the user navigating away from that page), the connection is closed. The connection can also be closed explicitly using the steps for closing a database connection.&quot;

So, obviously, the spec shouldn&apos;t reference GC. It would capture the intent to say something like:

&quot;If the connection object can no longer be used (for example, the user has navigated away from the page, or no references to the connection remain), the connection may be closed.&quot;

The more fundamental issue is that script can tell if GC has happened, e.g.

db = indexedDB.open(&apos;db&apos;, 1);
indexedDB.open(&apos;db&apos;, 2).onsuccess = function() { alert(&apos;GC happened&apos;); };
db = null;

... which would preclude the use of the API in this fashion in e.g. a hypothetical environment with infinite memory.

I think that ship has already sailed with connection-type resources. For example, with Web Sockets - open two sockets to a server, drop the reference to the first, and when the server detects that the first is unusable it can signal the second. Just riffing, though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103367</commentid>
    <comment_count>2</comment_count>
    <who name="Joshua Bell">jsbell</who>
    <bug_when>2014-04-03 18:22:32 +0000</bug_when>
    <thetext>We should check the IE behavior here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112415</commentid>
    <comment_count>3</comment_count>
    <who name="Joshua Bell">jsbell</who>
    <bug_when>2014-09-29 20:45:43 +0000</bug_when>
    <thetext>I noticed that XHR deals with this explicitly:

https://xhr.spec.whatwg.org/#garbage-collection

&quot;An XMLHttpRequest object must not be garbage collected if...&quot;

Chromium doesn&apos;t allow GC unless closePending or it has no event listeners. I believe FF does something similar (or maybe never GCs open databases?)

So we could add wording such as:

&quot;An IDBDatabase object must not be garbage collected if its closePending flag is false and it has one or more event listeners registers whose type is one of abort, error, and versionchange.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114864</commentid>
    <comment_count>4</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2014-11-12 20:03:57 +0000</bug_when>
    <thetext>I agree that it&apos;s unfortunate to expose GC behavior here. But I don&apos;t see any alternative solution.

The only option I could think of would be to never close databases unless the .close() function is explicitly called. It&apos;s not clear that that&apos;s web compatible at this point though.

So let&apos;s not hold up the v1 spec for this at the very least.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114865</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-11-12 20:09:52 +0000</bug_when>
    <thetext>I don&apos;t understand. What about addressing comment 3 at least?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114881</commentid>
    <comment_count>6</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2014-11-13 01:09:03 +0000</bug_when>
    <thetext>How is that different from the option I mentioned in comment 4?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>117120</commentid>
    <comment_count>7</comment_count>
    <who name="Joshua Bell">jsbell</who>
    <bug_when>2015-01-13 23:49:19 +0000</bug_when>
    <thetext>I added some blather similar to comment #3 into:

https://github.com/w3c/IndexedDB/commit/bdfc9964855d0ad650ade6da3ed0dd9b43b69d6a

... but I welcome more refinement. Leaving this open until we really nail down how to describe this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>122541</commentid>
    <comment_count>8</comment_count>
    <who name="Joshua Bell">jsbell</who>
    <bug_when>2015-08-10 20:01:57 +0000</bug_when>
    <thetext>Moved to https://github.com/w3c/IndexedDB/issues/29</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>