After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 650679 - Youtube plugin shouldn't load the categories on start
Youtube plugin shouldn't load the categories on start
Status: RESOLVED FIXED
Product: grilo
Classification: Other
Component: plugins
git master
Other Linux
: Normal normal
: ---
Assigned To: grilo-maint
grilo-maint
Depends on:
Blocks:
 
 
Reported: 2011-05-20 15:39 UTC by Juan A. Suarez Romero
Modified: 2011-06-08 18:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Do not preload Youtube categories (8.89 KB, patch)
2011-05-23 14:24 UTC, Juan A. Suarez Romero
reviewed Details | Review

Description Juan A. Suarez Romero 2011-05-20 15:39:57 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.
Comment 1 Juan A. Suarez Romero 2011-05-23 14:24:15 UTC
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.
Comment 2 Iago Toral 2011-05-31 06:45:27 UTC
Review of attachment 188382 [details] [review]:

Patch looks good to me.
Comment 3 Juan A. Suarez Romero 2011-06-08 18:32:12 UTC
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(-)