<?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>49096</bug_id>
          
          <creation_ts>2010-11-05 14:31:43 -0700</creation_ts>
          <short_desc>JSCallbackData::invokeCallback triggers layout from a worker thread</short_desc>
          <delta_ts>2010-11-05 15:48:13 -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>Layout and Rendering</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></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>47688</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Ryosuke Niwa">rniwa</reporter>
          <assigned_to name="Ryosuke Niwa">rniwa</assigned_to>
          <cc>darin</cc>
    
    <cc>dimich</cc>
    
    <cc>jamesr</cc>
    
    <cc>levin</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>305532</commentid>
    <comment_count>0</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2010-11-05 14:31:43 -0700</bug_when>
    <thetext>We call Document::updateStyleForAllDocuments() in JSCallbackData::invokeCallback without checking that we&apos;re in the main thread.

Stack trace:
#0    0x10109fe3f in WebCore::Document::updateStyleForAllDocuments at Document.cpp:1564
#1    0x10148acb1 in WebCore::JSCallbackData::invokeCallback at JSCallbackData.cpp:73
#2    0x1015e87b6 in WebCore::JSSQLTransactionSyncCallback::handleEvent at JSSQLTransactionSyncCallback.cpp:72
#3    0x1019e5520 in WebCore::SQLTransactionSync::execute at SQLTransactionSync.cpp:153
#4    0x101062abb in WebCore::DatabaseSync::runTransaction at DatabaseSync.cpp:152
#5    0x101062b9d in WebCore::DatabaseSync::transaction at DatabaseSync.cpp:134
#6    0x1014bdcf7 in WebCore::jsDatabaseSyncPrototypeFunctionTransaction at JSDatabaseSync.cpp:182
#7    0x3f93858041b8 in ??
#8    0x1001b65bd in JSC::JITCode::execute at JITCode.h:77
#9    0x1001b2648 in JSC::Interpreter::execute at Interpreter.cpp:759
#10    0x100181fa6 in JSC::evaluate at Completion.cpp:62
#11    0x101b43026 in WebCore::WorkerScriptController::evaluate at WorkerScriptController.cpp:128
#12    0x101b4320c in WebCore::WorkerScriptController::evaluate at WorkerScriptController.cpp:107
#13    0x101b44a48 in WebCore::WorkerThread::workerThread at WorkerThread.cpp:134
#14    0x101b44b41 in WebCore::WorkerThread::workerThreadStart at WorkerThread.cpp:117
#15    0x1002c974d in WTF::threadEntryPoint at Threading.cpp:65</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>305571</commentid>
    <comment_count>1</comment_count>
      <attachid>73128</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2010-11-05 15:13:25 -0700</bug_when>
    <thetext>Created attachment 73128
fixes the bug</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>305573</commentid>
    <comment_count>2</comment_count>
      <attachid>73128</attachid>
    <who name="David Levin">levin</who>
    <bug_when>2010-11-05 15:15:54 -0700</bug_when>
    <thetext>Comment on attachment 73128
fixes the bug

View in context: https://bugs.webkit.org/attachment.cgi?id=73128&amp;action=review

&gt; WebCore/bindings/js/JSCallbackData.cpp:73
&gt; +    if (context-&gt;isDocument())

It would be nice to not call this virtual function nearly twice in a row. Consider storing the value in a bool and using in both places.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>305574</commentid>
    <comment_count>3</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2010-11-05 15:16:40 -0700</bug_when>
    <thetext>Mn... somehow fast/workers/storage/use-same-database-in-page-and-workers.html always crash with the following error:

ERROR: Unable to turn on incremental auto-vacuum for database /var/folders/++/++3qwE++6+0++4RjPqRgNE+-Rj2/-Tmp-/DumpRenderTree-tplq1u/Databases/file__0/000000000000001d.db
(/Volumes/Data/webkit4/WebCore/storage/AbstractDatabase.cpp:251 virtual bool WebCore::AbstractDatabase::performOpenAndVerify(bool, WebCore::ExceptionCode&amp;))
ASSERTION FAILED: !protectedObjectCount()
(/Volumes/Data/webkit4/JavaScriptCore/runtime/Collector.cpp:262 void JSC::Heap::freeBlocks())

Should we fix this problem first?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>305589</commentid>
    <comment_count>4</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2010-11-05 15:40:20 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; (From update of attachment 73128 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=73128&amp;action=review
&gt; 
&gt; &gt; WebCore/bindings/js/JSCallbackData.cpp:73
&gt; &gt; +    if (context-&gt;isDocument())
&gt; 
&gt; It would be nice to not call this virtual function nearly twice in a row. Consider storing the value in a bool and using in both places.

Will do and land:

-    JSValue result = context-&gt;isDocument() 
+    bool contextIsDocument = context-&gt;isDocument();
+    JSValue result = contextIsDocument
         ? JSMainThreadExecState::call(exec, function, callType, callData, callback(), args)
         : JSC::call(exec, function, callType, callData, callback(), args);
     globalObject()-&gt;globalData().timeoutChecker.stop();
 
-    Document::updateStyleForAllDocuments();
+    if (contextIsDocument)
+        Document::updateStyleForAllDocuments();</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>305594</commentid>
    <comment_count>5</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2010-11-05 15:48:13 -0700</bug_when>
    <thetext>Committed r71455: &lt;http://trac.webkit.org/changeset/71455&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>73128</attachid>
            <date>2010-11-05 15:13:25 -0700</date>
            <delta_ts>2010-11-05 15:15:53 -0700</delta_ts>
            <desc>fixes the bug</desc>
            <filename>bug-49096-20101105151323.patch</filename>
            <type>text/plain</type>
            <size>2628</size>
            <attacher name="Ryosuke Niwa">rniwa</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlTG9n
CShyZXZpc2lvbiA3MTQ1MikKKysrIFdlYkNvcmUvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBA
IC0xLDMgKzEsMjIgQEAKKzIwMTAtMTEtMDUgIFJ5b3N1a2UgTml3YSAgPHJuaXdhQHdlYmtpdC5v
cmc+CisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCisKKyAgICAgICAgSlND
YWxsYmFja0RhdGE6Omludm9rZUNhbGxiYWNrIHRyaWdnZXJzIGxheW91dCBmcm9tIGEgd29ya2Vy
IHRocmVhZAorICAgICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9
NDkwOTYKKworICAgICAgICBGaXhlZCB0aGUgYnVnIGJ5IG9ubHkgY2FsbGluZyB1cGRhdGVTdHls
ZUZvckFsbERvY3VtZW50cyB3aGVuIHRoZSBjb250ZXh0IGlzIGRvY3VtZW50IGluCisgICAgICAg
IEpTQ2FsbGJhY2tEYXRhOjppbnZva2VDYWxsYmFjay4KKworICAgICAgICBObyBuZXcgdGVzdHMg
YXJlIGFkZGVkIHNpbmNlIG1hbnkgb2YgZXhpc3Rpbmcgd29ya2VycyB0ZXN0cyBoaXQgdGhlIGFk
ZGVkIGFzc2VydGlvbiB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
IAogdm9pZCBEb2N1bWVudDo6dXBkYXRlU3R5bGVGb3JBbGxEb2N1bWVudHMoKQogeworICAgIEFT
U0VSVChpc01haW5UaHJlYWQoKSk7CiAgICAgaWYgKCFkb2N1bWVudHNUaGF0TmVlZFN0eWxlUmVj
YWxjKQogICAgICAgICByZXR1cm47CiAKQEAgLTE1NzEsNiArMTU3Myw3IEBAIHZvaWQgRG9jdW1l
bnQ6OnVwZGF0ZVN0eWxlRm9yQWxsRG9jdW1lbnQKIAogdm9pZCBEb2N1bWVudDo6dXBkYXRlTGF5
b3V0KCkKIHsKKyAgICBBU1NFUlQoaXNNYWluVGhyZWFkKCkpOwogICAgIGlmIChFbGVtZW50KiBv
ZSA9IG93bmVyRWxlbWVudCgpKQogICAgICAgICBvZS0+ZG9jdW1lbnQoKS0+dXBkYXRlTGF5b3V0
KCk7CiAK
</data>
<flag name="review"
          id="63513"
          type_id="1"
          status="+"
          setter="levin"
    />
          </attachment>
      

    </bug>

</bugzilla>