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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>51557</bug_id>
          
          <creation_ts>2010-12-23 12:59:25 -0800</creation_ts>
          <short_desc>Visiting macnn.com often causes SQL spew via geolocation database</short_desc>
          <delta_ts>2011-07-28 07:59:11 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>65289</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Simon Fraser (smfr)">simon.fraser</reporter>
          <assigned_to name="Steve Block">steveblock</assigned_to>
          <cc>commit-queue</cc>
    
    <cc>jorlow</cc>
    
    <cc>levin</cc>
    
    <cc>sam</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>steveblock</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>326239</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2010-12-23 12:59:25 -0800</bug_when>
    <thetext>Sometimes, when loading macnn.com, I get this output on the console:

ERROR: SQLite database failed to load from 
Cause - out of memory
(/OpenSource/WebCore/platform/sql/SQLiteDatabase.cpp:70 bool WebCore::SQLiteDatabase::open(const WTF::String&amp;, bool))

This is coming out of geolocation code:

#0  WebCore::SQLiteDatabase::open (this=0x13739ad20, filename=@0x10bcc9008, forWebSQLDatabase=false) at /Volumes/InternalData/Development/webkit/OpenSource/WebCore/platform/sql/SQLiteDatabase.cpp:71
#1  0x000000010320e81c in WebCore::GeolocationPositionCache::readFromDatabaseImpl (this=0x10bcc8f10) at /Volumes/InternalData/Development/webkit/OpenSource/WebCore/page/GeolocationPositionCache.cpp:140
#2  0x000000010320ecb9 in WebCore::GeolocationPositionCache::readFromDatabase (cache=0x10bcc8f10) at /Volumes/InternalData/Development/webkit/OpenSource/WebCore/page/GeolocationPositionCache.cpp:132
#3  0x000000010320f504 in WebCore::CrossThreadTask1&lt;WebCore::GeolocationPositionCache*, WebCore::GeolocationPositionCache*&gt;::performTask (this=0x10bccd4c0, context=0x0) at CrossThreadTask.h:81
#4  0x000000010320ed29 in WebCore::GeolocationPositionCache::threadEntryPointImpl (this=0x10bcc8f10) at /Volumes/InternalData/Development/webkit/OpenSource/WebCore/page/GeolocationPositionCache.cpp:121
#5  0x000000010320ed57 in WebCore::GeolocationPositionCache::threadEntryPoint (object=0x10bcc8f10) at /Volumes/InternalData/Development/webkit/OpenSource/WebCore/page/GeolocationPositionCache.cpp:113
#6  0x0000000101a8d149 in WTF::threadEntryPoint (contextData=0x10bcbb0b0) at /Volumes/InternalData/Development/webkit/OpenSource/JavaScriptCore/wtf/Threading.cpp:65

filename is a null string.

So:
1. Why is getting window.geolocatiaon spawning a thread and trying to open a database?
2. Why is the database path empty?
3. Why is the SQL error so totally bogus?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>326240</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2010-12-23 12:59:44 -0800</bug_when>
    <thetext>&lt;rdar://problem/8800389&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>326270</commentid>
    <comment_count>2</comment_count>
    <who name="Steve Block">steveblock</who>
    <bug_when>2010-12-23 13:56:43 -0800</bug_when>
    <thetext>Apologies. This was caused by http://trac.webkit.org/changeset/74354

I&apos;ll look into this ASAP, but please feel free to roll back my change if required.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>327642</commentid>
    <comment_count>3</comment_count>
    <who name="Steve Block">steveblock</who>
    <bug_when>2010-12-29 11:42:51 -0800</bug_when>
    <thetext>&gt; 1. Why is getting window.geolocatiaon spawning a thread and trying to open a database?
This thread is to handle reading from and writing to the database used to cache Geolocation positions. We start the thread as soon as the navigator.geolocation object is accessed so that it&apos;s ready when Geolocation is used.

&gt; 2. Why is the database path empty?
This path can be set by calling GeolocationPositionCache::setDatabasePath(). It seems this is not called by the Mac port (Geolocation will work even without a cache). Prior to the refactoring in http://trac.webkit.org/changeset/74226, if the path is not set we early-out when trying to open the DB. Since that refactoring, if the path is not set we use an empty path so the DB open fails. I&apos;ll send a patch to restore the early-out behaviour to avoid the log spew.

&gt; 3. Why is the SQL error so totally bogus?
I have no idea. I don&apos;t think this is specific to Geolocation.

&gt; Apologies. This was caused by http://trac.webkit.org/changeset/74354
It seems this is not the cause after all.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>327647</commentid>
    <comment_count>4</comment_count>
      <attachid>77634</attachid>
    <who name="Steve Block">steveblock</who>
    <bug_when>2010-12-29 11:45:13 -0800</bug_when>
    <thetext>Created attachment 77634
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>327702</commentid>
    <comment_count>5</comment_count>
      <attachid>77634</attachid>
    <who name="Sam Weinig">sam</who>
    <bug_when>2010-12-29 14:24:15 -0800</bug_when>
    <thetext>Comment on attachment 77634
Patch

Why are we hitting the cache when just fetching the geolocation object.  This seems silly since people often fetch the geolocation object in feature detection, even if they are not using it.

r=me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>327869</commentid>
    <comment_count>6</comment_count>
    <who name="Steve Block">steveblock</who>
    <bug_when>2010-12-30 02:53:13 -0800</bug_when>
    <thetext>&gt; Why are we hitting the cache when just fetching the geolocation object.
The idea is to start the DB thread as soon as navigator.geolocation is accessed. Then when a Geolocation method is called, we potentially use a cached position if one is available, but we don&apos;t wait for the cache. If we don&apos;t start the DB thread until a Geolocation method is called, the cache will almost certainly never be used for this first method call.

&gt; This 
&gt; seems silly since people often fetch the geolocation object in feature
&gt; detection, even if they are not using it.
Really, do you think it&apos;s likely that people feature detect for a feature they don&apos;t plan to use?

An alternative is to change the logic such that the DB thread is not started until a Geolocation method is called, but then have the Geolocation object wait for a cache response before instructing the GeolocationController to do work to get a position fix. This is a more involved change which could complicate the logic considerably. I&apos;ll look into it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>327876</commentid>
    <comment_count>7</comment_count>
      <attachid>77634</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2010-12-30 03:32:31 -0800</bug_when>
    <thetext>Comment on attachment 77634
Patch

Clearing flags on attachment: 77634

Committed r74794: &lt;http://trac.webkit.org/changeset/74794&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>327877</commentid>
    <comment_count>8</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2010-12-30 03:32:37 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>328184</commentid>
    <comment_count>9</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2010-12-31 09:09:40 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; &gt; 1. Why is getting window.geolocatiaon spawning a thread and trying to open a database?
&gt; This thread is to handle reading from and writing to the database used to cache Geolocation positions. We start the thread as soon as the navigator.geolocation object is accessed so that it&apos;s ready when Geolocation is used.

I agree with Sam that this should not happen. Please file a bug on this too.

&gt; &gt; 2. Why is the database path empty?
&gt; This path can be set by calling GeolocationPositionCache::setDatabasePath(). It seems this is not called by the Mac port 

Please file a bug on that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>328508</commentid>
    <comment_count>10</comment_count>
    <who name="Steve Block">steveblock</who>
    <bug_when>2011-01-03 03:25:45 -0800</bug_when>
    <thetext>&gt; I agree with Sam that this should not happen. Please file a bug on this too.
Filed Bug 51814

&gt; &gt; This path can be set by calling GeolocationPositionCache::setDatabasePath().
&gt; &gt; It seems this is not called by the Mac port 
&gt; Please file a bug on that.
Filed Bug 51813.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>77634</attachid>
            <date>2010-12-29 11:45:13 -0800</date>
            <delta_ts>2010-12-30 03:32:30 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-51557-20101229194511.patch</filename>
            <type>text/plain</type>
            <size>3032</size>
            <attacher name="Steve Block">steveblock</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlTG9n
CShyZXZpc2lvbiA3NDc1MCkKKysrIFdlYkNvcmUvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBA
IC0xLDMgKzEsMjUgQEAKKzIwMTAtMTItMjkgIFN0ZXZlIEJsb2NrICA8c3RldmVibG9ja0Bnb29n
bGUuY29tPgorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAg
IFZpc2l0aW5nIG1hY25uLmNvbSBvZnRlbiBjYXVzZXMgU1FMIHNwZXcgdmlhIGdlb2xvY2F0aW9u
IGRhdGFiYXNlCisgICAgICAgIGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9p
ZD01MTU1NworCisgICAgICAgIElmIHRoZSBHZW9sb2NhdGlvbiBwb3NpdGlvbiBjYWNoZSBkYXRh
YmFzZSBwYXRoIGhhcyBub3QgYmVlbiBzZXQsIGVhcmx5LW91dAorICAgICAgICByYXRo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