Fix crash due to RemoteLayerTreeDisplayRefreshMonitor outliving RemoteLayerTreeDrawin...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jul 2015 00:23:05 +0000 (00:23 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jul 2015 00:23:05 +0000 (00:23 +0000)
commit6eb63d84c023e069e3b47abdb484891185dbe740
tree47a5b314356f960fbcbc64d67b6b92cac9cd83e4
parent1ef6e15d2fce76ec3777401f385e28cec1e129b3
Fix crash due to RemoteLayerTreeDisplayRefreshMonitor outliving RemoteLayerTreeDrawingArea
https://bugs.webkit.org/show_bug.cgi?id=147124
<rdar://problem/21582858>

Reviewed by Simon Fraser.

Refactors RemoteLayerTreeDisplayRefreshMonitor to use a weak pointer rather than a reference
to its RemoteLayerTreeDrawingArea, since the drawing area may be deallocated before the monitor
in some rare cases. This rarely caused pages using requestAnimationFrame to crash on iOS. However,
this should not be the case: logically, a RemoteLayerTreeDrawingArea should always outlive its
refresh monitors. Refer to https://bugs.webkit.org/show_bug.cgi?id=147128 for more details.

* WebProcess/WebPage/Cocoa/RemoteLayerTreeDisplayRefreshMonitor.h:
* WebProcess/WebPage/Cocoa/RemoteLayerTreeDisplayRefreshMonitor.mm:
(WebKit::RemoteLayerTreeDisplayRefreshMonitor::RemoteLayerTreeDisplayRefreshMonitor):
(WebKit::RemoteLayerTreeDisplayRefreshMonitor::~RemoteLayerTreeDisplayRefreshMonitor): On destruction, checks
    first to see whether or not the drawing area has been deallocated before telling it to update its monitors.
(WebKit::RemoteLayerTreeDisplayRefreshMonitor::requestRefreshCallback):
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
(WebKit::RemoteLayerTreeDrawingArea::createWeakPtr): Creates and returns a new weak pointer to itself.
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187050 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/Cocoa/RemoteLayerTreeDisplayRefreshMonitor.h
Source/WebKit2/WebProcess/WebPage/Cocoa/RemoteLayerTreeDisplayRefreshMonitor.mm
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm