GNOME Bugzilla – Bug 650679
Youtube plugin shouldn't load the categories on start
Last modified: 2011-06-08 18:32:12 UTC
When Youtube is loaded, it starts immediately to fetch data from Youtube place to build the browse category, even if Youtube is not being browsed. This is a waste of network bandwith and also it adds some delays to applications loading the plugin. To get a best understanding about how this impacts, let's think that in the case of Totem, where a Grilo plugin can be used, everytime a user clicks a video to play it, the Youtube content would be getting data from inet, even in the case it is not being used. A proposed solution is to load the category on demand, so only if user browse that category it will be obtained, and from that moment on it could be reused again.
Created attachment 188382 [details] [review] Do not preload Youtube categories This patch should be applied on 0.1.x branch. This patch avoids pre-calculating the list of categories and childcounts when plugin is loaded. Instead, categories are computed when user tries to browse through them. And it they are computed only once. In this patch, childcount is only calculated when a browse is performed. Thus, initially the childcount in, let's say, in "Categories", is unknown. Only when user browses through "Categories", the children are obtained and therefore childcount is calculated for the future. If we want to calculate always the childcount, then it is clear tat when user asks for "Categories" childcount, we need to internally do a browse to collect all the elements and compute the value of childcount. Clearly, we should treat "childcount" as an slow count. But as this value is cached for the future, next time we ask again for "childcount", it is just returned, so in this case we shouldn't consider it a slow key. For this reason I just took the easiest approach: only return known childcount when we have collected the required data, and "unknown" when we do not have it.
Review of attachment 188382 [details] [review]: Patch looks good to me.
Fixed. commit 5e03770c1e4c8644d8467698f8ead7b83ce7f155 Author: Juan A. Suarez Romero <jasuarez@igalia.com> Date: Mon May 23 14:11:19 2011 +0000 youtube: Do not preload categories Get categories and feeds only when it is required, instead of doing when loading the plugin. This will prevent getting information that possible will not be used (if user do not perform a browse). As consequence of this, childcount is only computed when the user really browses through the category. This fixes https://bugzilla.gnome.org/show_bug.cgi?id=650679 Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com> src/media/youtube/grl-youtube.c | 144 ++++++++------------------------------- 1 files changed, 29 insertions(+), 115 deletions(-)