Title: [201092] trunk/Source/WebInspectorUI
Revision
201092
Author
bb...@apple.com
Date
2016-05-18 12:29:14 -0700 (Wed, 18 May 2016)

Log Message

Web Inspector: race between frontend and backend both starting timeline recordings causes console assert
https://bugs.webkit.org/show_bug.cgi?id=157850
<rdar://problem/26349229>

Reviewed by Joseph Pecoraro.

If TimelineManager has created a fresh recording and the Timeline.autoCaptureStarted
event comes before Timeline.recordingStarted, then the manager will try to start the
same recording twice. In this scenario, the manager should just wait until the
Timeline.recordingStarted event comes, since it causes TimelineMangare to set up
the isCapturing flag and other state.

* UserInterface/Controllers/TimelineManager.js:
(WebInspector.TimelineManager):
(WebInspector.TimelineManager.prototype.startCapturing):
(WebInspector.TimelineManager.prototype.capturingStarted):
(WebInspector.TimelineManager.prototype.autoCaptureStarted):
Add a new flag, this._waitingForCapturingStartedEvent. If true, don't start the
recording in response to this event.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (201091 => 201092)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-05-18 19:10:14 UTC (rev 201091)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-05-18 19:29:14 UTC (rev 201092)
@@ -1,3 +1,25 @@
+2016-05-18  Brian Burg  <bb...@apple.com>
+
+        Web Inspector: race between frontend and backend both starting timeline recordings causes console assert
+        https://bugs.webkit.org/show_bug.cgi?id=157850
+        <rdar://problem/26349229>
+
+        Reviewed by Joseph Pecoraro.
+
+        If TimelineManager has created a fresh recording and the Timeline.autoCaptureStarted
+        event comes before Timeline.recordingStarted, then the manager will try to start the
+        same recording twice. In this scenario, the manager should just wait until the
+        Timeline.recordingStarted event comes, since it causes TimelineMangare to set up
+        the isCapturing flag and other state.
+
+        * UserInterface/Controllers/TimelineManager.js:
+        (WebInspector.TimelineManager):
+        (WebInspector.TimelineManager.prototype.startCapturing):
+        (WebInspector.TimelineManager.prototype.capturingStarted):
+        (WebInspector.TimelineManager.prototype.autoCaptureStarted):
+        Add a new flag, this._waitingForCapturingStartedEvent. If true, don't start the
+        recording in response to this event.
+
 2016-05-18  Matt Baker  <mattba...@apple.com>
 
         Web Inspector: REGRESSION(r197488): Incorrect start time in Rendering Frames timeline grid

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js (201091 => 201092)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js	2016-05-18 19:10:14 UTC (rev 201091)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js	2016-05-18 19:29:14 UTC (rev 201092)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013, 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -42,6 +42,7 @@
         this._persistentNetworkTimeline = new WebInspector.NetworkTimeline;
 
         this._isCapturing = false;
+        this._waitingForCapturingStartedEvent = false;
         this._isCapturingPageReload = false;
         this._autoCaptureOnPageLoad = false;
         this._mainResourceForAutoCapturing = null;
@@ -170,6 +171,8 @@
         if (!this._activeRecording || shouldCreateRecording)
             this._loadNewRecording();
 
+        this._waitingForCapturingStartedEvent = true;
+
         this.dispatchEventToListeners(WebInspector.TimelineManager.Event.CapturingWillStart);
 
         this._activeRecording.start();
@@ -221,6 +224,7 @@
         if (this._isCapturing)
             return;
 
+        this._waitingForCapturingStartedEvent = false;
         this._isCapturing = true;
 
         this._lastDeadTimeTickle = 0;
@@ -265,7 +269,11 @@
         if (this._isCapturing)
             this.stopCapturing();
 
-        this.startCapturing(true);
+        // We may already have an fresh TimelineRecording created if autoCaptureStarted is received
+        // between sending the Timeline.start command and receiving Timeline.capturingStarted event.
+        // In that case, there is no need to call startCapturing again. Reuse the fresh recording.
+        if (!this._waitingForCapturingStartedEvent)
+            this.startCapturing(true);
 
         this._shouldSetAutoCapturingMainResource = true;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to