Title: [280653] trunk/Source/WebKit
Revision
280653
Author
simon.fra...@apple.com
Date
2021-08-04 13:20:52 -0700 (Wed, 04 Aug 2021)

Log Message

Crash in DisplayLink::notifyObserversDisplayWasRefreshed() on macOS
https://bugs.webkit.org/show_bug.cgi?id=228790
<rdar://81338621>

Reviewed by Tim Horton.

Defend against DisplayLink::nominalFramesPerSecondFromDisplayLink() returning zero,
which can result in a later divide by zero in m_currentUpdate.nextUpdate().

* UIProcess/mac/DisplayLink.cpp:
(WebKit::DisplayLink::nominalFramesPerSecondFromDisplayLink):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (280652 => 280653)


--- trunk/Source/WebKit/ChangeLog	2021-08-04 19:43:00 UTC (rev 280652)
+++ trunk/Source/WebKit/ChangeLog	2021-08-04 20:20:52 UTC (rev 280653)
@@ -1,3 +1,17 @@
+2021-08-04  Simon Fraser  <simon.fra...@apple.com>
+
+        Crash in DisplayLink::notifyObserversDisplayWasRefreshed() on macOS
+        https://bugs.webkit.org/show_bug.cgi?id=228790
+        <rdar://81338621>
+
+        Reviewed by Tim Horton.
+
+        Defend against DisplayLink::nominalFramesPerSecondFromDisplayLink() returning zero,
+        which can result in a later divide by zero in m_currentUpdate.nextUpdate().
+
+        * UIProcess/mac/DisplayLink.cpp:
+        (WebKit::DisplayLink::nominalFramesPerSecondFromDisplayLink):
+
 2021-08-04  Said Abou-Hallawa  <s...@apple.com>
 
         [GPUProcess] REGRESSION: A noticeable slow down when browsing Live Photos album on iCloud.com

Modified: trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp (280652 => 280653)


--- trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp	2021-08-04 19:43:00 UTC (rev 280652)
+++ trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp	2021-08-04 20:20:52 UTC (rev 280653)
@@ -79,7 +79,11 @@
 WebCore::FramesPerSecond DisplayLink::nominalFramesPerSecondFromDisplayLink(CVDisplayLinkRef displayLink)
 {
     CVTime refreshPeriod = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(displayLink);
-    return round((double)refreshPeriod.timeScale / (double)refreshPeriod.timeValue);
+    if (!refreshPeriod.timeValue)
+        return WebCore::FullSpeedFramesPerSecond;
+
+    WebCore::FramesPerSecond result = round((double)refreshPeriod.timeScale / (double)refreshPeriod.timeValue);
+    return result ?: WebCore::FullSpeedFramesPerSecond;
 }
 
 void DisplayLink::addObserver(IPC::Connection& connection, DisplayLinkObserverID observerID, WebCore::FramesPerSecond preferredFramesPerSecond)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to