Skip to content
Permalink
Browse files
Many CVDisplayLink threads created and destroyed while watching a You…
…Tube video

https://bugs.webkit.org/show_bug.cgi?id=181396

Reviewed by Simon Fraser.

When watching some YouTube videos (or any video with default controls), event handlers for
the "timeupdate" event which use rAF will cause the underlying platform objects to be
destroyed in between "timeupdate" events being fired, since they occur every 250ms, and rAF
objects are destroyed every 166ms (or 10/60hz). Update this constant to destroy the
underlying objects every 333ms (or 20/60hz) so that this common pattern doesn't lead to
excessive rAF platform object turnover.

* platform/Logging.h:
* platform/graphics/DisplayRefreshMonitor.h:
(WebCore::DisplayRefreshMonitor::shouldBeTerminated const):
* platform/graphics/DisplayRefreshMonitor.cpp:
(WebCore::DisplayRefreshMonitor::displayDidRefresh):
* platform/graphics/DisplayRefreshMonitorManager.cpp:
(WebCore::DisplayRefreshMonitorManager::createMonitorForClient):
(WebCore::DisplayRefreshMonitorManager::displayDidRefresh):


Canonical link: https://commits.webkit.org/197313@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226664 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
jernoble committed Jan 9, 2018
1 parent 3696a84 commit 17414ac293d9aae369e06d7f4075d8b81b4e204c
Showing 5 changed files with 29 additions and 1 deletion.
@@ -1,3 +1,26 @@
2018-01-09 Jer Noble <jer.noble@apple.com>

Many CVDisplayLink threads created and destroyed while watching a YouTube video
https://bugs.webkit.org/show_bug.cgi?id=181396

Reviewed by Simon Fraser.

When watching some YouTube videos (or any video with default controls), event handlers for
the "timeupdate" event which use rAF will cause the underlying platform objects to be
destroyed in between "timeupdate" events being fired, since they occur every 250ms, and rAF
objects are destroyed every 166ms (or 10/60hz). Update this constant to destroy the
underlying objects every 333ms (or 20/60hz) so that this common pattern doesn't lead to
excessive rAF platform object turnover.

* platform/Logging.h:
* platform/graphics/DisplayRefreshMonitor.h:
(WebCore::DisplayRefreshMonitor::shouldBeTerminated const):
* platform/graphics/DisplayRefreshMonitor.cpp:
(WebCore::DisplayRefreshMonitor::displayDidRefresh):
* platform/graphics/DisplayRefreshMonitorManager.cpp:
(WebCore::DisplayRefreshMonitorManager::createMonitorForClient):
(WebCore::DisplayRefreshMonitorManager::displayDidRefresh):

2018-01-09 Zalan Bujtas <zalan@apple.com>

[RenderTreeBuilder] Move RenderElement addChild mutation logic to RenderTreeBuilder
@@ -78,6 +78,7 @@ namespace WebCore {
M(PopupBlocking) \
M(Progress) \
M(RemoteInspector) \
M(RequestAnimationFrame) \
M(ResourceLoading) \
M(ResourceLoadObserver) \
M(ResourceLoadStatistics) \
@@ -85,6 +85,7 @@ void DisplayRefreshMonitor::displayDidRefresh()
{
{
LockHolder lock(m_mutex);
LOG(RequestAnimationFrame, "DisplayRefreshMonitor::displayDidRefresh(%p) - m_scheduled(%d), m_unscheduledFireCount(%d)", this, m_scheduled, m_unscheduledFireCount);
if (!m_scheduled)
++m_unscheduledFireCount;
else
@@ -56,7 +56,7 @@ class DisplayRefreshMonitor : public RefCounted<DisplayRefreshMonitor> {

bool shouldBeTerminated() const
{
const int maxInactiveFireCount = 10;
const int maxInactiveFireCount = 20;
return !m_scheduled && m_unscheduledFireCount > maxInactiveFireCount;
}

@@ -30,6 +30,7 @@

#include "DisplayRefreshMonitor.h"
#include "DisplayRefreshMonitorClient.h"
#include "Logging.h"
#include <wtf/CurrentTime.h>

namespace WebCore {
@@ -56,6 +57,7 @@ DisplayRefreshMonitor* DisplayRefreshMonitorManager::createMonitorForClient(Disp
if (!monitor)
return nullptr;

LOG(RequestAnimationFrame, "DisplayRefreshMonitorManager::createMonitorForClient() - created monitor %p", monitor.get());
monitor->addClient(client);
DisplayRefreshMonitor* result = monitor.get();
m_monitors.append(WTFMove(monitor));
@@ -105,6 +107,7 @@ void DisplayRefreshMonitorManager::displayDidRefresh(DisplayRefreshMonitor& moni
{
if (!monitor.shouldBeTerminated())
return;
LOG(RequestAnimationFrame, "DisplayRefreshMonitorManager::displayDidRefresh() - destroying monitor %p", &monitor);

size_t monitorIndex = m_monitors.find(&monitor);
if (monitorIndex != notFound)

0 comments on commit 17414ac

Please sign in to comment.