Occasional crashes in commitTransientZoom's transaction completion block
[WebKit-https.git] / Source / WebKit2 / WebProcess / WebPage / mac / TiledCoreAnimationDrawingArea.mm
index 5ed3ea9cee2bf580c747d0521b87ab3a87098494..4f610363a9a454d66281049793ac354a7f76e1ae 100644 (file)
@@ -637,14 +637,17 @@ void TiledCoreAnimationDrawingArea::commitTransientZoom(double scale, FloatPoint
     if (PlatformCALayer* shadowLayer = shadowLayerForTransientZoom())
         shadowCALayer = shadowLayer->platformLayer();
 
-    PlatformCALayer* zoomLayer = layerForTransientZoom();
+    RefPtr<PlatformCALayer> zoomLayer = layerForTransientZoom();
+    RefPtr<WebPage> page = &m_webPage;
 
     [CATransaction begin];
-    [CATransaction setCompletionBlock:^(void) {
+    [CATransaction setCompletionBlock:[zoomLayer, shadowCALayer, page, scale, origin] () {
         zoomLayer->removeAnimationForKey("transientZoomCommit");
         if (shadowCALayer)
             [shadowCALayer removeAllAnimations];
-        applyTransientZoomToPage(scale, origin);
+
+        if (TiledCoreAnimationDrawingArea* drawingArea = static_cast<TiledCoreAnimationDrawingArea*>(page->drawingArea()))
+            drawingArea->applyTransientZoomToPage(scale, origin);
     }];
 
     zoomLayer->addAnimationForKey("transientZoomCommit", renderViewAnimation.get());