Title: [131588] trunk/Source/WebKit2
- Revision
- 131588
- Author
- [email protected]
- Date
- 2012-10-17 04:54:15 -0700 (Wed, 17 Oct 2012)
Log Message
[WK2][GTK] Favicons are incorrectly released before receiving the actual data
https://bugs.webkit.org/show_bug.cgi?id=99492
Reviewed by Carlos Garcia Campos.
Don't release the icon for a page URL in the first stage of the
asynchronous call webkit_favicon_database_get_favicon() but do it
later instead, to avoid a race condition with the initial
synchronization process the first time we request an icon which is
actually in the icon database, but has not made available yet.
* UIProcess/API/gtk/WebKitFaviconDatabase.cpp:
(GetFaviconSurfaceAsyncData::~GetFaviconSurfaceAsyncData): Release
here the icon for the page URL if not a valid icon has been found.
(GetFaviconSurfaceAsyncData): Add a new boolean parameter to flag
when a given icon for a page URL should be released.
(getIconSurfaceSynchronously): Don't release the icon, just return 0.
(processPendingIconsForPageURL): If a valid icon is got at this
point, disable the flag shouldReleaseIconForPageURL not to release
the icon later on.
(webkit_favicon_database_get_favicon): Make sure we retain the
icon for a given page URL before trying to retrieve it from the
IconDatabase, and that we flag it to be released in case not a
valid icon has been found yet.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (131587 => 131588)
--- trunk/Source/WebKit2/ChangeLog 2012-10-17 11:50:25 UTC (rev 131587)
+++ trunk/Source/WebKit2/ChangeLog 2012-10-17 11:54:15 UTC (rev 131588)
@@ -1,3 +1,30 @@
+2012-10-17 Mario Sanchez Prada <[email protected]>
+
+ [WK2][GTK] Favicons are incorrectly released before receiving the actual data
+ https://bugs.webkit.org/show_bug.cgi?id=99492
+
+ Reviewed by Carlos Garcia Campos.
+
+ Don't release the icon for a page URL in the first stage of the
+ asynchronous call webkit_favicon_database_get_favicon() but do it
+ later instead, to avoid a race condition with the initial
+ synchronization process the first time we request an icon which is
+ actually in the icon database, but has not made available yet.
+
+ * UIProcess/API/gtk/WebKitFaviconDatabase.cpp:
+ (GetFaviconSurfaceAsyncData::~GetFaviconSurfaceAsyncData): Release
+ here the icon for the page URL if not a valid icon has been found.
+ (GetFaviconSurfaceAsyncData): Add a new boolean parameter to flag
+ when a given icon for a page URL should be released.
+ (getIconSurfaceSynchronously): Don't release the icon, just return 0.
+ (processPendingIconsForPageURL): If a valid icon is got at this
+ point, disable the flag shouldReleaseIconForPageURL not to release
+ the icon later on.
+ (webkit_favicon_database_get_favicon): Make sure we retain the
+ icon for a given page URL before trying to retrieve it from the
+ IconDatabase, and that we flag it to be released in case not a
+ valid icon has been found yet.
+
2012-10-17 Grzegorz Czajkowski <[email protected]>, Michal Roj <[email protected]>
Implementation of spellchecking feature.
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.cpp (131587 => 131588)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.cpp 2012-10-17 11:50:25 UTC (rev 131587)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFaviconDatabase.cpp 2012-10-17 11:54:15 UTC (rev 131588)
@@ -107,10 +107,17 @@
}
struct GetFaviconSurfaceAsyncData {
+ ~GetFaviconSurfaceAsyncData()
+ {
+ if (shouldReleaseIconForPageURL)
+ faviconDatabase->priv->iconDatabase->releaseIconForPageURL(pageURL);
+ }
+
GRefPtr<WebKitFaviconDatabase> faviconDatabase;
String pageURL;
RefPtr<cairo_surface_t> icon;
GRefPtr<GCancellable> cancellable;
+ bool shouldReleaseIconForPageURL;
};
WEBKIT_DEFINE_ASYNC_DATA_STRUCT(GetFaviconSurfaceAsyncData)
@@ -118,21 +125,17 @@
{
ASSERT(isMainThread());
- database->priv->iconDatabase->retainIconForPageURL(pageURL);
-
// The exact size we pass is irrelevant to the iconDatabase code.
// We must pass something greater than 0x0 to get an icon.
WebCore::Image* iconImage = database->priv->iconDatabase->imageForPageURL(pageURL, WebCore::IntSize(1, 1));
if (!iconImage) {
g_set_error(error, WEBKIT_FAVICON_DATABASE_ERROR, WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_UNKNOWN, _("Unknown favicon for page %s"), pageURL.utf8().data());
- database->priv->iconDatabase->releaseIconForPageURL(pageURL);
return 0;
}
WebCore::NativeImagePtr icon = iconImage->nativeImageForCurrentFrame();
if (!icon) {
g_set_error(error, WEBKIT_FAVICON_DATABASE_ERROR, WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_NOT_FOUND, _("Page %s does not have a favicon"), pageURL.utf8().data());
- database->priv->iconDatabase->releaseIconForPageURL(pageURL);
return 0;
}
@@ -160,8 +163,10 @@
if (!g_cancellable_is_cancelled(data->cancellable.get())) {
if (error)
g_simple_async_result_take_error(result, error.release());
- else
+ else {
data->icon = icon;
+ data->shouldReleaseIconForPageURL = false;
+ }
}
g_simple_async_result_complete(result);
@@ -291,6 +296,8 @@
return;
}
+ priv->iconDatabase->retainIconForPageURL(data->pageURL);
+
// We ask for the icon directly. If we don't get the icon data now,
// we'll be notified later (even if the database is still importing icons).
GOwnPtr<GError> error;
@@ -300,6 +307,9 @@
return;
}
+ // At this point we still don't know whether we will get a valid icon for pageURL.
+ data->shouldReleaseIconForPageURL = true;
+
if (g_error_matches(error.get(), WEBKIT_FAVICON_DATABASE_ERROR, WEBKIT_FAVICON_DATABASE_ERROR_FAVICON_NOT_FOUND)) {
g_simple_async_result_take_error(result.get(), error.release());
g_simple_async_result_complete_in_idle(result.get());
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes