Title: [186098] trunk/Source/WebInspectorUI
Revision
186098
Author
commit-qu...@webkit.org
Date
2015-06-29 17:27:29 -0700 (Mon, 29 Jun 2015)

Log Message

Web Inspector: iOS 8: Resources Timeline Data does not show up
https://bugs.webkit.org/show_bug.cgi?id=146433

Patch by Joseph Pecoraro <pecor...@apple.com> on 2015-06-29
Reviewed by Timothy Hatcher.

There were a couple issues with initializing the legacy base timestamp
for attempting to dynamically compute monotonically increasing timestamps
for timeline events for legacy backends.

    * Sometimes legacy timestamps were in seconds since epochs,
      sometimes milliseconds. The frontend did not handle both.

    * On navigations, even while resetting the base timestamp for
      the first new record received, the main resource still had
      a will send request time computed from the previous page's
      time system. This patch re-uses the original timestamp for
      this main resource as the new base and all future records
      are computed relative to this.

* UserInterface/Controllers/FrameResourceManager.js:
(WebInspector.FrameResourceManager.prototype.resourceRequestWillBeSent):
(WebInspector.FrameResourceManager.prototype._addNewResourceToFrame):
* UserInterface/Models/Resource.js:
(WebInspector.Resource):
(WebInspector.Resource.prototype.get originalRequestWillBeSentTimestamp):
For legacy timestamp calculations, save the original request will be sent
timestamp on the Resource in case it is needed.

* UserInterface/Controllers/TimelineManager.js:
(WebInspector.TimelineManager.prototype._loadNewRecording):
When auto-starting a new recording for a navigation / reload, use the
main resource's request will be sent timestamp as the new base.

* UserInterface/Models/TimelineRecording.js:
Address legacy timeline timestamps by handling both legacy timestamps
that may be seconds / milliseconds.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (186097 => 186098)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-06-30 00:24:05 UTC (rev 186097)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-06-30 00:27:29 UTC (rev 186098)
@@ -1,5 +1,44 @@
 2015-06-29  Joseph Pecoraro  <pecor...@apple.com>
 
+        Web Inspector: iOS 8: Resources Timeline Data does not show up
+        https://bugs.webkit.org/show_bug.cgi?id=146433
+
+        Reviewed by Timothy Hatcher.
+
+        There were a couple issues with initializing the legacy base timestamp
+        for attempting to dynamically compute monotonically increasing timestamps
+        for timeline events for legacy backends.
+
+            * Sometimes legacy timestamps were in seconds since epochs,
+              sometimes milliseconds. The frontend did not handle both.
+
+            * On navigations, even while resetting the base timestamp for
+              the first new record received, the main resource still had
+              a will send request time computed from the previous page's
+              time system. This patch re-uses the original timestamp for
+              this main resource as the new base and all future records
+              are computed relative to this.
+
+        * UserInterface/Controllers/FrameResourceManager.js:
+        (WebInspector.FrameResourceManager.prototype.resourceRequestWillBeSent):
+        (WebInspector.FrameResourceManager.prototype._addNewResourceToFrame):
+        * UserInterface/Models/Resource.js:
+        (WebInspector.Resource):
+        (WebInspector.Resource.prototype.get originalRequestWillBeSentTimestamp):
+        For legacy timestamp calculations, save the original request will be sent
+        timestamp on the Resource in case it is needed.
+
+        * UserInterface/Controllers/TimelineManager.js:
+        (WebInspector.TimelineManager.prototype._loadNewRecording):
+        When auto-starting a new recording for a navigation / reload, use the
+        main resource's request will be sent timestamp as the new base.
+
+        * UserInterface/Models/TimelineRecording.js:
+        Address legacy timeline timestamps by handling both legacy timestamps
+        that may be seconds / milliseconds.
+
+2015-06-29  Joseph Pecoraro  <pecor...@apple.com>
+
         REGRESSION: Web Inspector: Jump to Definition is broken
         https://bugs.webkit.org/show_bug.cgi?id=146376
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js (186097 => 186098)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js	2015-06-30 00:24:05 UTC (rev 186097)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js	2015-06-30 00:27:29 UTC (rev 186098)
@@ -177,6 +177,13 @@
         if (this._waitingForMainFrameResourceTreePayload)
             return;
 
+        // COMPATIBILITY (iOS 8): Timeline timestamps for legacy backends are computed
+        // dynamically from the first backend timestamp received. For navigations we
+        // need to reset that base timestamp, and an appropriate timestamp to use is
+        // the new main resource's will be sent timestamp. So save this value on the
+        // resource in case it becomes a main resource.
+        var originalRequestWillBeSentTimestamp = timestamp;
+
         var elapsedTime = WebInspector.timelineManager.computeElapsedTime(timestamp);
         var resource = this._resourceRequestIdentifierMap[requestIdentifier];
         if (resource) {
@@ -189,7 +196,7 @@
         var initiatorSourceCodeLocation = this._initiatorSourceCodeLocationFromPayload(initiator);
 
         // This is a new request, make a new resource and add it to the right frame.
-        resource = this._addNewResourceToFrame(requestIdentifier, frameIdentifier, loaderIdentifier, request.url, type, request.method, request.headers, request.postData, elapsedTime, null, null, initiatorSourceCodeLocation);
+        resource = this._addNewResourceToFrame(requestIdentifier, frameIdentifier, loaderIdentifier, request.url, type, request.method, request.headers, request.postData, elapsedTime, null, null, initiatorSourceCodeLocation, originalRequestWillBeSentTimestamp);
 
         // Associate the resource with the requestIdentifier so it can be found in future loading events.
         this._resourceRequestIdentifierMap[requestIdentifier] = resource;
@@ -380,7 +387,7 @@
 
     // Private
 
-    _addNewResourceToFrame(requestIdentifier, frameIdentifier, loaderIdentifier, url, type, requestMethod, requestHeaders, requestData, elapsedTime, frameName, frameSecurityOrigin, initiatorSourceCodeLocation)
+    _addNewResourceToFrame(requestIdentifier, frameIdentifier, loaderIdentifier, url, type, requestMethod, requestHeaders, requestData, elapsedTime, frameName, frameSecurityOrigin, initiatorSourceCodeLocation, originalRequestWillBeSentTimestamp)
     {
         console.assert(!this._waitingForMainFrameResourceTreePayload);
 
@@ -394,12 +401,12 @@
             else if (frame.provisionalMainResource && frame.provisionalMainResource.url ="" url && frame.provisionalLoaderIdentifier === loaderIdentifier)
                 resource = frame.provisionalMainResource;
             else {
-                resource = new WebInspector.Resource(url, null, type, loaderIdentifier, requestIdentifier, requestMethod, requestHeaders, requestData, elapsedTime, initiatorSourceCodeLocation);
+                resource = new WebInspector.Resource(url, null, type, loaderIdentifier, requestIdentifier, requestMethod, requestHeaders, requestData, elapsedTime, initiatorSourceCodeLocation, originalRequestWillBeSentTimestamp);
                 this._addResourceToFrame(frame, resource);
             }
         } else {
             // This is a new request for a new frame, which is always the main resource.
-            resource = new WebInspector.Resource(url, null, type, loaderIdentifier, requestIdentifier, requestMethod, requestHeaders, requestData, elapsedTime, initiatorSourceCodeLocation);
+            resource = new WebInspector.Resource(url, null, type, loaderIdentifier, requestIdentifier, requestMethod, requestHeaders, requestData, elapsedTime, initiatorSourceCodeLocation, originalRequestWillBeSentTimestamp);
             frame = new WebInspector.Frame(frameIdentifier, frameName, frameSecurityOrigin, loaderIdentifier, resource);
             this._frameIdentifierMap[frame.id] = frame;
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js (186097 => 186098)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js	2015-06-30 00:24:05 UTC (rev 186097)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js	2015-06-30 00:27:29 UTC (rev 186098)
@@ -455,6 +455,18 @@
             oldRecording.unloaded();
 
         this._activeRecording = newRecording;
+
+        // COMPATIBILITY (iOS 8): When using Legacy timestamps, a navigation will have computed
+        // the main resource's will send request timestamp in terms of the last page's base timestamp.
+        // Now that we have navigated, we should reset the legacy base timestamp and the
+        // will send request timestamp for the new main resource. This way, all new timeline
+        // records will be computed relative to the new navigation.
+        if (this._autoCapturingMainResource && WebInspector.TimelineRecording.isLegacy) {
+            console.assert(this._autoCapturingMainResource.originalRequestWillBeSentTimestamp);
+            this._activeRecording.setLegacyBaseTimestamp(this._autoCapturingMainResource.originalRequestWillBeSentTimestamp);
+            this._autoCapturingMainResource._requestSentTimestamp = 0;
+        }
+
         this.dispatchEventToListeners(WebInspector.TimelineManager.Event.RecordingLoaded, {oldRecording});
     }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js (186097 => 186098)


--- trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js	2015-06-30 00:24:05 UTC (rev 186097)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js	2015-06-30 00:27:29 UTC (rev 186098)
@@ -25,7 +25,7 @@
 
 WebInspector.Resource = class Resource extends WebInspector.SourceCode
 {
-    constructor(url, mimeType, type, loaderIdentifier, requestIdentifier, requestMethod, requestHeaders, requestData, requestSentTimestamp, initiatorSourceCodeLocation)
+    constructor(url, mimeType, type, loaderIdentifier, requestIdentifier, requestMethod, requestHeaders, requestData, requestSentTimestamp, initiatorSourceCodeLocation, originalRequestWillBeSentTimestamp)
     {
         super();
 
@@ -45,6 +45,7 @@
         this._responseHeaders = {};
         this._parentFrame = null;
         this._initiatorSourceCodeLocation = initiatorSourceCodeLocation || null;
+        this._originalRequestWillBeSentTimestamp = originalRequestWillBeSentTimestamp || null;
         this._requestSentTimestamp = requestSentTimestamp || NaN;
         this._responseReceivedTimestamp = NaN;
         this._lastRedirectReceivedTimestamp = NaN;
@@ -139,6 +140,11 @@
         return this._initiatorSourceCodeLocation;
     }
 
+    get originalRequestWillBeSentTimestamp()
+    {
+        return this._originalRequestWillBeSentTimestamp;
+    }
+
     get type()
     {
         return this._type;

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/TimelineRecording.js (186097 => 186098)


--- trunk/Source/WebInspectorUI/UserInterface/Models/TimelineRecording.js	2015-06-30 00:24:05 UTC (rev 186097)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/TimelineRecording.js	2015-06-30 00:27:29 UTC (rev 186098)
@@ -197,17 +197,35 @@
         if (!timestamp || isNaN(timestamp))
             return NaN;
 
-        // COMPATIBILITY (iOS8): old backends send timestamps (milliseconds since the epoch), rather
-        // than seconds elapsed since timeline capturing started. We approximate the latter by
+        // COMPATIBILITY (iOS8): old backends send timestamps (seconds or milliseconds since the epoch),
+        // rather than seconds elapsed since timeline capturing started. We approximate the latter by
         // subtracting the start timestamp, as old versions did not use monotonic times.
+        if (WebInspector.TimelineRecording.isLegacy === undefined)
+            WebInspector.TimelineRecording.isLegacy = timestamp > WebInspector.TimelineRecording.TimestampThresholdForLegacyRecordConversion;
+
+        if (!WebInspector.TimelineRecording.isLegacy)
+            return timestamp;
+
+        // If the record's start time is large, but not really large, then it is seconds since epoch
+        // not millseconds since epoch, so convert it to milliseconds.
+        if (timestamp < WebInspector.TimelineRecording.TimestampThresholdForLegacyAssumedMilliseconds)
+            timestamp *= 1000;
+
         if (isNaN(this._legacyFirstRecordedTimestamp))
             this._legacyFirstRecordedTimestamp = timestamp;
 
-        // If the record's start time sems unreasonably large, treat it as a legacy timestamp.
-        if (timestamp > WebInspector.TimelineRecording.TimestampThresholdForLegacyRecordConversion)
-            return (timestamp - this._legacyFirstRecordedTimestamp) / 1000.0;
+        // Return seconds since the first recorded value.
+        return (timestamp - this._legacyFirstRecordedTimestamp) / 1000.0;
+    }
 
-        return timestamp;
+    setLegacyBaseTimestamp(timestamp)
+    {
+        console.assert(isNaN(this._legacyFirstRecordedTimestamp));
+
+        if (timestamp < WebInspector.TimelineRecording.TimestampThresholdForLegacyAssumedMilliseconds)
+            timestamp *= 1000;
+
+        this._legacyFirstRecordedTimestamp = timestamp;
     }
 
     // Private
@@ -253,4 +271,6 @@
     TimesUpdated: "timeline-recording-times-updated"
 };
 
-WebInspector.TimelineRecording.TimestampThresholdForLegacyRecordConversion = 28800000; // Date.parse("Jan 1, 1970")
+WebInspector.TimelineRecording.isLegacy = undefined;
+WebInspector.TimelineRecording.TimestampThresholdForLegacyRecordConversion = 10000000; // Some value not near zero.
+WebInspector.TimelineRecording.TimestampThresholdForLegacyAssumedMilliseconds = 1420099200000; // Date.parse("Jan 1, 2015"). Milliseconds since epoch.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to