Title: [185777] trunk
Revision
185777
Author
mattba...@apple.com
Date
2015-06-19 16:35:53 -0700 (Fri, 19 Jun 2015)

Log Message

Web Inspector: TimelineAgent needs to handle nested runloops
https://bugs.webkit.org/show_bug.cgi?id=145090

Reviewed by Joseph Pecoraro.

Source/WebCore:

Previously nested run loops caused InspectorTimelineAgent to prematurely pop the current run loop record. This
patch adds a counter to track the run loop nesting level, and rendering frame records are only pushed/popped
when the nesting level is zero. Run loop entry/exit notifications received while the debugger is paused do not
affect the nesting level.

* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::internalStart):
(WebCore::InspectorTimelineAgent::internalStop):
(WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
* inspector/InspectorTimelineAgent.h:

LayoutTests:

* TestExpectations:
Unskip tests after improvements to nested runloop handling in InspectorTimelineAgent.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (185776 => 185777)


--- trunk/LayoutTests/ChangeLog	2015-06-19 23:33:39 UTC (rev 185776)
+++ trunk/LayoutTests/ChangeLog	2015-06-19 23:35:53 UTC (rev 185777)
@@ -1,3 +1,13 @@
+2015-06-19  Matt Baker  <mattba...@apple.com>
+
+        Web Inspector: TimelineAgent needs to handle nested runloops
+        https://bugs.webkit.org/show_bug.cgi?id=145090
+
+        Reviewed by Joseph Pecoraro.
+
+        * TestExpectations:
+        Unskip tests after improvements to nested runloop handling in InspectorTimelineAgent.
+
 2015-06-19  Andy Estes  <aes...@apple.com>
 
         Various assertion failures occur when executing script in the midst of DOM insertion

Modified: trunk/LayoutTests/TestExpectations (185776 => 185777)


--- trunk/LayoutTests/TestExpectations	2015-06-19 23:33:39 UTC (rev 185776)
+++ trunk/LayoutTests/TestExpectations	2015-06-19 23:35:53 UTC (rev 185777)
@@ -524,27 +524,6 @@
 
 webkit.org/b/145390 storage/indexeddb/deleteIndex-bug110792.html [ Pass Failure ]
 
-webkit.org/b/145090 inspector/debugger/break-on-exception.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-exception-catch.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-exception-finally.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-exception-native.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-exception-throw-in-promise.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-exception-throw-in-promise-with-catch.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-exception-throw-in-promise-then.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-exception-throw-in-promise-then-with-catch.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-exception-throw-in-promise-rethrow-in-catch.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-exception-window-onerror.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-uncaught-exception.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-uncaught-exception-catch.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-uncaught-exception-finally.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-uncaught-exception-native.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-uncaught-exception-throw-in-promise.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-uncaught-exception-throw-in-promise-with-catch.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-uncaught-exception-throw-in-promise-then.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-uncaught-exception-throw-in-promise-then-with-catch.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-uncaught-exception-throw-in-promise-rethrow-in-catch.html [ Skip ]
-webkit.org/b/145090 inspector/debugger/break-on-uncaught-exception-window-onerror.html [ Skip ]
-
 # DumpRenderTree does not allow GIFs to animate, thus animated GIF tests don't work in WebKit1.
 fast/images/animated-gif-no-layout.html [ ImageOnlyFailure ]
 fast/images/gif-loop-count.html [ ImageOnlyFailure ]

Modified: trunk/Source/WebCore/ChangeLog (185776 => 185777)


--- trunk/Source/WebCore/ChangeLog	2015-06-19 23:33:39 UTC (rev 185776)
+++ trunk/Source/WebCore/ChangeLog	2015-06-19 23:35:53 UTC (rev 185777)
@@ -1,3 +1,21 @@
+2015-06-19  Matt Baker  <mattba...@apple.com>
+
+        Web Inspector: TimelineAgent needs to handle nested runloops
+        https://bugs.webkit.org/show_bug.cgi?id=145090
+
+        Reviewed by Joseph Pecoraro.
+
+        Previously nested run loops caused InspectorTimelineAgent to prematurely pop the current run loop record. This
+        patch adds a counter to track the run loop nesting level, and rendering frame records are only pushed/popped
+        when the nesting level is zero. Run loop entry/exit notifications received while the debugger is paused do not
+        affect the nesting level.
+
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::internalStart):
+        (WebCore::InspectorTimelineAgent::internalStop):
+        (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
+        * inspector/InspectorTimelineAgent.h:
+
 2015-06-19  Brent Fulgham  <bfulg...@apple.com>
 
         Follow-up fix to r185766.

Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp (185776 => 185777)


--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp	2015-06-19 23:33:39 UTC (rev 185776)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp	2015-06-19 23:35:53 UTC (rev 185777)
@@ -140,7 +140,10 @@
     else
         m_maxCallStackDepth = 5;
 
-    m_instrumentingAgents->inspectorEnvironment().executionStopwatch()->start();
+    // If the debugger is paused the environment's stopwatch will be stopped, and shouldn't be
+    // restarted until the debugger continues.
+    if (!m_scriptDebugServer->isPaused())
+        m_instrumentingAgents->inspectorEnvironment().executionStopwatch()->start();
 
     m_instrumentingAgents->setInspectorTimelineAgent(this);
 
@@ -153,27 +156,32 @@
 
 #if PLATFORM(COCOA)
     m_frameStartObserver = RunLoopObserver::create(0, [this]() {
-        if (!m_enabled || m_didStartRecordingRunLoop)
+        if (!m_enabled || m_scriptDebugServer->isPaused())
             return;
 
-        pushCurrentRecord(InspectorObject::create(), TimelineRecordType::RenderingFrame, false, nullptr);
-        m_didStartRecordingRunLoop = true;
+        if (!m_runLoopNestingLevel)
+            pushCurrentRecord(InspectorObject::create(), TimelineRecordType::RenderingFrame, false, nullptr);
+        m_runLoopNestingLevel++;
     });
 
     m_frameStopObserver = RunLoopObserver::create(frameStopRunLoopOrder, [this]() {
-        if (!m_enabled || !m_didStartRecordingRunLoop)
+        if (!m_enabled || m_scriptDebugServer->isPaused())
             return;
 
-        didCompleteCurrentRecord(TimelineRecordType::RenderingFrame);
-        m_didStartRecordingRunLoop = false;
+        ASSERT(m_runLoopNestingLevel > 0);
+        m_runLoopNestingLevel--;
+        if (!m_runLoopNestingLevel)
+            didCompleteCurrentRecord(TimelineRecordType::RenderingFrame);
     });
 
-    m_frameStartObserver->schedule(currentRunLoop(), kCFRunLoopAfterWaiting | kCFRunLoopBeforeTimers);
-    m_frameStopObserver->schedule(currentRunLoop(), kCFRunLoopBeforeWaiting | kCFRunLoopExit);
+    m_frameStartObserver->schedule(currentRunLoop(), kCFRunLoopEntry | kCFRunLoopAfterWaiting);
+    m_frameStopObserver->schedule(currentRunLoop(), kCFRunLoopExit | kCFRunLoopBeforeWaiting);
 
-    // Create a runloop record immediately in order to capture the rest of the current runloop.
+    // Create a runloop record and increment the runloop nesting level, to capture the current turn of the main runloop
+    // (which is the outer runloop if recording started while paused in the debugger).
     pushCurrentRecord(InspectorObject::create(), TimelineRecordType::RenderingFrame, false, nullptr);
-    m_didStartRecordingRunLoop = true;
+
+    m_runLoopNestingLevel = 1;
 #endif
 
     if (m_frontendDispatcher)
@@ -198,13 +206,11 @@
 #if PLATFORM(COCOA)
     m_frameStartObserver = nullptr;
     m_frameStopObserver = nullptr;
-    if (m_didStartRecordingRunLoop) {
-        m_didStartRecordingRunLoop = false;
+    m_runLoopNestingLevel = 0;
 
-        // Complete all pending records to prevent discarding events that are currently in progress.
-        while (!m_recordStack.isEmpty())
-            didCompleteCurrentRecord(m_recordStack.last().type);
-    }
+    // Complete all pending records to prevent discarding events that are currently in progress.
+    while (!m_recordStack.isEmpty())
+        didCompleteCurrentRecord(m_recordStack.last().type);
 #endif
 
     clearRecordStack();
@@ -722,7 +728,7 @@
     , m_client(client)
     , m_enabled(false)
     , m_enabledFromFrontend(false)
-    , m_didStartRecordingRunLoop(false)
+    , m_runLoopNestingLevel(0)
 {
 }
 

Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.h (185776 => 185777)


--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.h	2015-06-19 23:33:39 UTC (rev 185776)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.h	2015-06-19 23:35:53 UTC (rev 185777)
@@ -251,7 +251,7 @@
     std::unique_ptr<WebCore::RunLoopObserver> m_frameStartObserver;
     std::unique_ptr<WebCore::RunLoopObserver> m_frameStopObserver;
 #endif
-    bool m_didStartRecordingRunLoop;
+    int m_runLoopNestingLevel;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to