Title: [284280] branches/safari-612-branch/Source/WebCore
Revision
284280
Author
[email protected]
Date
2021-10-15 15:38:53 -0700 (Fri, 15 Oct 2021)

Log Message

Cherry-pick r281879. rdar://problem/83954217

    Improve time precision when cross-origin isolated via COOP+COEP
    https://bugs.webkit.org/show_bug.cgi?id=228137
    <rdar://problem/81197138>

    Reviewed by Ryosuke Niwa.

    Increase the precision of our high precision time (used by performance.now()) from
    1ms to 20us when cross-origin isolated via COOP=same-origin + COEP=require-corp.
    Precision remains the same (1ms) when not cross-origin isolated.

    This aligns our behavior with Firefox.

    Note that Chrome provides higher precision (100us in general and 5us when
    cross-origin-isolated).

    * dom/ScriptExecutionContext.cpp:
    (WebCore::ScriptExecutionContext::setCrossOriginMode):
    * page/Performance.cpp:
    (WebCore::Performance::reduceTimeResolution):
    (WebCore::Performance::allowHighPrecisionTime):
    * page/Performance.h:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281879 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (284279 => 284280)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2021-10-15 22:37:24 UTC (rev 284279)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2021-10-15 22:38:53 UTC (rev 284280)
@@ -1,5 +1,58 @@
 2021-10-15  Russell Epstein  <[email protected]>
 
+        Cherry-pick r281879. rdar://problem/83954217
+
+    Improve time precision when cross-origin isolated via COOP+COEP
+    https://bugs.webkit.org/show_bug.cgi?id=228137
+    <rdar://problem/81197138>
+    
+    Reviewed by Ryosuke Niwa.
+    
+    Increase the precision of our high precision time (used by performance.now()) from
+    1ms to 20us when cross-origin isolated via COOP=same-origin + COEP=require-corp.
+    Precision remains the same (1ms) when not cross-origin isolated.
+    
+    This aligns our behavior with Firefox.
+    
+    Note that Chrome provides higher precision (100us in general and 5us when
+    cross-origin-isolated).
+    
+    * dom/ScriptExecutionContext.cpp:
+    (WebCore::ScriptExecutionContext::setCrossOriginMode):
+    * page/Performance.cpp:
+    (WebCore::Performance::reduceTimeResolution):
+    (WebCore::Performance::allowHighPrecisionTime):
+    * page/Performance.h:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281879 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-09-01  Chris Dumez  <[email protected]>
+
+            Improve time precision when cross-origin isolated via COOP+COEP
+            https://bugs.webkit.org/show_bug.cgi?id=228137
+            <rdar://problem/81197138>
+
+            Reviewed by Ryosuke Niwa.
+
+            Increase the precision of our high precision time (used by performance.now()) from
+            1ms to 20us when cross-origin isolated via COOP=same-origin + COEP=require-corp.
+            Precision remains the same (1ms) when not cross-origin isolated.
+
+            This aligns our behavior with Firefox.
+
+            Note that Chrome provides higher precision (100us in general and 5us when
+            cross-origin-isolated).
+
+            * dom/ScriptExecutionContext.cpp:
+            (WebCore::ScriptExecutionContext::setCrossOriginMode):
+            * page/Performance.cpp:
+            (WebCore::Performance::reduceTimeResolution):
+            (WebCore::Performance::allowHighPrecisionTime):
+            * page/Performance.h:
+
+2021-10-15  Russell Epstein  <[email protected]>
+
         Cherry-pick r283572. rdar://problem/83953133
 
     Web Inspector: Show color space for canvases in the Graphics tab on the overview cards

Modified: branches/safari-612-branch/Source/WebCore/dom/ScriptExecutionContext.cpp (284279 => 284280)


--- branches/safari-612-branch/Source/WebCore/dom/ScriptExecutionContext.cpp	2021-10-15 22:37:24 UTC (rev 284279)
+++ branches/safari-612-branch/Source/WebCore/dom/ScriptExecutionContext.cpp	2021-10-15 22:38:53 UTC (rev 284280)
@@ -47,6 +47,7 @@
 #include "MessagePort.h"
 #include "Navigator.h"
 #include "Page.h"
+#include "Performance.h"
 #include "PublicURLManager.h"
 #include "RejectedPromiseTracker.h"
 #include "ResourceRequest.h"
@@ -628,6 +629,8 @@
 void ScriptExecutionContext::setCrossOriginMode(CrossOriginMode crossOriginMode)
 {
     globalCrossOriginMode = crossOriginMode;
+    if (crossOriginMode == CrossOriginMode::Isolated)
+        Performance::allowHighPrecisionTime();
 }
 
 CrossOriginMode ScriptExecutionContext::crossOriginMode()

Modified: branches/safari-612-branch/Source/WebCore/page/Performance.cpp (284279 => 284280)


--- branches/safari-612-branch/Source/WebCore/page/Performance.cpp	2021-10-15 22:37:24 UTC (rev 284279)
+++ branches/safari-612-branch/Source/WebCore/page/Performance.cpp	2021-10-15 22:38:53 UTC (rev 284280)
@@ -58,6 +58,9 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(Performance);
 
+constexpr Seconds highTimePrecision { 20_us };
+static Seconds timePrecision { 1_ms };
+
 Performance::Performance(ScriptExecutionContext* context, MonotonicTime timeOrigin)
     : ContextDestructionObserver(context)
     , m_resourceTimingBufferFullTimer(*this, &Performance::resourceTimingBufferFullTimerFired) // FIXME: Migrate this to the event loop as well. https://bugs.webkit.org/show_bug.cgi?id=229044
@@ -92,11 +95,16 @@
 
 Seconds Performance::reduceTimeResolution(Seconds seconds)
 {
-    double resolution = (1000_us).seconds();
+    double resolution = timePrecision.seconds();
     double reduced = std::floor(seconds.seconds() / resolution) * resolution;
     return Seconds(reduced);
 }
 
+void Performance::allowHighPrecisionTime()
+{
+    timePrecision = highTimePrecision;
+}
+
 DOMHighResTimeStamp Performance::relativeTimeFromTimeOriginInReducedResolution(MonotonicTime timestamp) const
 {
     Seconds seconds = timestamp - m_timeOrigin;

Modified: branches/safari-612-branch/Source/WebCore/page/Performance.h (284279 => 284280)


--- branches/safari-612-branch/Source/WebCore/page/Performance.h	2021-10-15 22:37:24 UTC (rev 284279)
+++ branches/safari-612-branch/Source/WebCore/page/Performance.h	2021-10-15 22:38:53 UTC (rev 284280)
@@ -106,6 +106,7 @@
     void registerPerformanceObserver(PerformanceObserver&);
     void unregisterPerformanceObserver(PerformanceObserver&);
 
+    static void allowHighPrecisionTime();
     static Seconds reduceTimeResolution(Seconds);
 
     DOMHighResTimeStamp relativeTimeFromTimeOriginInReducedResolution(MonotonicTime) const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to