Title: [165883] releases/WebKitGTK/webkit-2.2/Source/WebKit2
Revision
165883
Author
carlo...@webkit.org
Date
2014-03-19 02:19:24 -0700 (Wed, 19 Mar 2014)

Log Message

Merge r165489 - [GTK] Runtime error when page is closed while print operation is in progress
https://bugs.webkit.org/show_bug.cgi?id=129869

Reviewed by Anders Carlsson.

Sometimes when the page is closed right after printing the web
process aborts with the runtime message "pure virtual method
called terminate called without an active exception".
This happens because the page is closed when the pages have been
printed, but print job is still ongoing sending the data to the
printer. When print job finishes, we try to notify the UI process
sending the print callback message using WebPage::send(), but the
web page object has been destroyed. The virtual method it complains
about is probably MessageSender::messageSenderDestinationID() used
by send(). Since our print operation is always asynchronous, we
need a way to notify the web page when the print operation has
actually finished to clean it up, but also notify the print
operation when the page has been closed to not try to notify the
UI process in that case.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::close): Call disconnectFromPage to notify the
print operation in case there's an ongoing print job.
(WebKit::WebPage::endPrinting): Do not cleanup the print operation
here, since the print opertation might not have finished yet.
(WebKit::WebPage::didFinishPrintOperation): Send
PrintFinishedCallback message to the Ui process and cleanup the
print operation.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp:
(WebKit::WebPrintOperationGtk::disconnectFromPage): Set m_webPage
to nullptr.
(WebKit::WebPrintOperationGtk::printDone): Call
didFinishPrintOperation() is the web page hasn't been closed.
* WebProcess/WebPage/gtk/WebPrintOperationGtk.h:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.2/Source/WebKit2/ChangeLog (165882 => 165883)


--- releases/WebKitGTK/webkit-2.2/Source/WebKit2/ChangeLog	2014-03-19 09:16:47 UTC (rev 165882)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit2/ChangeLog	2014-03-19 09:19:24 UTC (rev 165883)
@@ -1,3 +1,41 @@
+2014-03-12  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK] Runtime error when page is closed while print operation is in progress
+        https://bugs.webkit.org/show_bug.cgi?id=129869
+
+        Reviewed by Anders Carlsson.
+
+        Sometimes when the page is closed right after printing the web
+        process aborts with the runtime message "pure virtual method
+        called terminate called without an active exception".
+        This happens because the page is closed when the pages have been
+        printed, but print job is still ongoing sending the data to the
+        printer. When print job finishes, we try to notify the UI process
+        sending the print callback message using WebPage::send(), but the
+        web page object has been destroyed. The virtual method it complains
+        about is probably MessageSender::messageSenderDestinationID() used
+        by send(). Since our print operation is always asynchronous, we
+        need a way to notify the web page when the print operation has
+        actually finished to clean it up, but also notify the print
+        operation when the page has been closed to not try to notify the
+        UI process in that case.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::close): Call disconnectFromPage to notify the
+        print operation in case there's an ongoing print job.
+        (WebKit::WebPage::endPrinting): Do not cleanup the print operation
+        here, since the print opertation might not have finished yet.
+        (WebKit::WebPage::didFinishPrintOperation): Send
+        PrintFinishedCallback message to the Ui process and cleanup the
+        print operation.
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp:
+        (WebKit::WebPrintOperationGtk::disconnectFromPage): Set m_webPage
+        to nullptr.
+        (WebKit::WebPrintOperationGtk::printDone): Call
+        didFinishPrintOperation() is the web page hasn't been closed.
+        * WebProcess/WebPage/gtk/WebPrintOperationGtk.h:
+
 2014-03-06  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK] Close the page when the view is disposed instead of when finalized

Modified: releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (165882 => 165883)


--- releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-03-19 09:16:47 UTC (rev 165882)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2014-03-19 09:19:24 UTC (rev 165883)
@@ -845,6 +845,13 @@
     }
 #endif
 
+#if PLATFORM(GTK)
+    if (m_printOperation) {
+        m_printOperation->disconnectFromPage();
+        m_printOperation = nullptr;
+    }
+#endif
+
     m_sandboxExtensionTracker.invalidate();
 
 #if ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC)
@@ -3405,9 +3412,6 @@
 void WebPage::endPrinting()
 {
     drawingArea()->setLayerTreeStateIsFrozen(false);
-#if PLATFORM(GTK)
-    m_printOperation = 0;
-#endif
     m_printContext = nullptr;
 }
 
@@ -3533,7 +3537,6 @@
 }
 
 #elif PLATFORM(GTK)
-
 void WebPage::drawPagesForPrinting(uint64_t frameID, const PrintInfo& printInfo, uint64_t callbackID)
 {
     beginPrinting(frameID, printInfo);
@@ -3544,6 +3547,12 @@
 
     send(Messages::WebPageProxy::VoidCallback(callbackID));
 }
+
+void WebPage::didFinishPrintOperation(const WebCore::ResourceError& error, uint64_t callbackID)
+{
+    send(Messages::WebPageProxy::PrintFinishedCallback(error, callbackID));
+    m_printOperation = nullptr;
+}
 #endif
 
 void WebPage::savePDFToFileInDownloadsFolder(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size)

Modified: releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/WebPage.h (165882 => 165883)


--- releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-03-19 09:16:47 UTC (rev 165882)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/WebPage.h	2014-03-19 09:19:24 UTC (rev 165883)
@@ -543,6 +543,7 @@
     void drawPagesToPDF(uint64_t frameID, const PrintInfo&, uint32_t first, uint32_t count, uint64_t callbackID);
 #elif PLATFORM(GTK)
     void drawPagesForPrinting(uint64_t frameID, const PrintInfo&, uint64_t callbackID);
+    void didFinishPrintOperation(const WebCore::ResourceError&, uint64_t callbackID);
 #endif
 
     void setMediaVolume(float);

Modified: releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp (165882 => 165883)


--- releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp	2014-03-19 09:16:47 UTC (rev 165882)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp	2014-03-19 09:19:24 UTC (rev 165883)
@@ -412,6 +412,11 @@
         g_source_remove(m_printPagesIdleId);
 }
 
+void WebPrintOperationGtk::disconnectFromPage()
+{
+    m_webPage = nullptr;
+}
+
 int WebPrintOperationGtk::pageCount() const
 {
     return m_printContext ? m_printContext->pageCount() : 0;
@@ -682,8 +687,9 @@
         g_source_remove(m_printPagesIdleId);
     m_printPagesIdleId = 0;
 
-    // Print finished or failed, notify the UI process that we are done.
-    m_webPage->send(Messages::WebPageProxy::PrintFinishedCallback(error, m_callbackID));
+    // Print finished or failed, notify the UI process that we are done if the page hasn't been closed.
+    if (m_webPage)
+        m_webPage->didFinishPrintOperation(error, m_callbackID);
 }
 
 void WebPrintOperationGtk::print(cairo_surface_t* surface, double xDPI, double yDPI)

Modified: releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.h (165882 => 165883)


--- releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.h	2014-03-19 09:16:47 UTC (rev 165882)
+++ releases/WebKitGTK/webkit-2.2/Source/WebKit2/WebProcess/WebPage/gtk/WebPrintOperationGtk.h	2014-03-19 09:19:24 UTC (rev 165883)
@@ -72,6 +72,8 @@
     bool collateCopies() const { return m_collateCopies; }
     double scale() const { return m_scale; }
 
+    void disconnectFromPage();
+
     virtual void startPrint(WebCore::PrintContext*, uint64_t callbackID) = 0;
 
 protected:
@@ -92,6 +94,7 @@
     void prepareContextToDraw();
     void printPagesDone();
     void printDone(const WebCore::ResourceError&);
+    void sendPrintFinished(const WebCore::ResourceError&);
 
     WebPage* m_webPage;
     GRefPtr<GtkPrintSettings> m_printSettings;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to