Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    2,836

    LMS caching menu item image

    Does LMS caches the menu items images when a plugin creates a menu? (the "image" property that I set in the callback to display a menu which in my case is a link to a web image)
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

  2. #2
    Senior Member pippin's Avatar
    Join Date
    Oct 2007
    Location
    Berlin
    Posts
    13,872
    It caches the scaled thumbnails requested by the UIs
    ---
    learn more about iPeng, the iPhone and iPad remote for the Squeezebox and
    Logitech UE Smart Radio as well as iPeng Party, the free Party-App,
    at penguinlovesmusic.com
    New: iPeng 9, the Universal App for iPhone, iPad and Apple Watch

  3. #3
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    2,836
    Quote Originally Posted by pippin View Post
    It caches the scaled thumbnails requested by the UIs
    Thanks, that makes sense but it does not seem to work for me. My plugin builds the menu the following way
    Code:
    sub initPlugin {
    	my $class = shift;
    
    	$class->SUPER::initPlugin(
    		feed   => \&toplevel,
    		tag    => 'LCI',
    		menu   => 'radios',
    		is_app => 1,
    		weight => 10,
    	);
    
    	if ( main::WEBUI ) {
    		require Plugins::LCI::Settings;
    		Plugins::LCI::Settings->new;
    	}
    	
    	for my $recent (reverse @{$prefs->get('recent')}) {
    		$recentlyPlayed{ $recent->{'url'} } = $recent;
    	}
    	
    	Slim::Control::Request::addDispatch(['LCI', 'info'], 
    		[1, 1, 1, \&cliInfoQuery]);
    		
    	
    }
    Where function "toplevel" reads a set of channels from a station and build the list

    Code:
    sub toplevel {
    	my ($client, $callback, $args) = @_;
    	
    	my $items = [ { name => cstring($client, 'PLUGIN_LCI_RECENTLYPLAYED'), image => getIcon(), url  => \&recentHandler, } ];
    		
    	addChannels($client, $callback, $args, $items);
    }
    
    sub addChannels {
    	my ($client, $cb, $args, $items) = @_;
    	my $page = "/pages/emissions/?type=other&filter=emissions-lci";
    	
    	Plugins::LCI::API::search( $page, sub {
    	
    		my $result = shift;
    		my $data = $result->{page}->{data};
    
                    ... some more code ...		
    
    		for my $entry (@{$data->{data}->{elementList}}) {
    							
    			push @$items, {
    				name  => $entry->{text},
    				type  => 'playlist',
    				url   => \&searchEpisodes,
    				image => $entry->{pictures}->{elementList}[0]->{dpi}[0]->{url},
    				passthrough 	=> [ { link => $entry->{link} } ],
    			};
    			
    		}
    		
    		$cb->( $items );
    	
    	} );	
    }
    The link set in image => is the same at every call of the top menu build (I'm sure it's the case because the result of the search function is cached and I hit the cache), but what I observe is that displaying the menu takes forever because LMS seems to grab each image from the URL (if I don't set the image, building the menu is immediate)

    I get there is something I don't understand in what is really cached
    Last edited by philippe_44; 2017-03-19 at 19:29.
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

  4. #4
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,476

    LMS caching menu item image

    > The link set in image => I know is the same at every call of the top
    > menu build (I'm even more sure it's the case because the result of the
    > search function is cached and I hit the cache), but what I observe is
    > that displaying the menu takes forever because LMS seems to grab each
    > image from the URL (if I don't set the image, building the menu is
    > immediate)


    So... the problem isn't that you wouldn't ge the right artwork, but that
    loading it is slow? What's an icon's URL? What UI? Did you check what
    LMS is doing with --debug artwork,artwork.imageproxy?

    --

    Michael

  5. #5
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    2,836
    Quote Originally Posted by mherger View Post
    > The link set in image => I know is the same at every call of the top
    > menu build (I'm even more sure it's the case because the result of the
    > search function is cached and I hit the cache), but what I observe is
    > that displaying the menu takes forever because LMS seems to grab each
    > image from the URL (if I don't set the image, building the menu is
    > immediate)


    So... the problem isn't that you wouldn't ge the right artwork, but that
    loading it is slow? What's an icon's URL? What UI? Did you check what
    LMS is doing with --debug artwork,artwork.imageproxy?

    --

    Michael
    Yes, I have the artwork, but it's very slow are reloading every time. Typical URL would be: http://photos.lci.fr/images/767/1316...6e5c-0@1x.jpeg. It(s the default UI. I've not checked at debug log of LMS, sorry, I will
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

  6. #6
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,476

    LMS caching menu item image

    > Yes, I have the artwork, but it's very slow are reloading every time.
    > Typical URL would be:
    > http://photos.lci.fr/images/767/1316... 1x (DOT) jpeg.
    > It(s the default UI. I've not checked at debug log of LMS, sorry, I will


    Is this the URL showing up in eg. the web UI? Then LMS isn't involved in
    loading/displaying it and doesn't re-size it either. That seems wrong to me.

    Are you seeing this behaviour with all LMS versions?
    --

    Michael

  7. #7
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    2,836
    Quote Originally Posted by mherger View Post
    > Yes, I have the artwork, but it's very slow are reloading every time.
    > Typical URL would be:
    > http://photos.lci.fr/images/767/1316... 1x (DOT) jpeg.
    > It(s the default UI. I've not checked at debug log of LMS, sorry, I will


    Is this the URL showing up in eg. the web UI? Then LMS isn't involved in
    loading/displaying it and doesn't re-size it either. That seems wrong to me.

    Are you seeing this behaviour with all LMS versions?
    --

    Michael
    I've set the debug levels for artwork. I see a first time that LMS makes the HTTP queries to get the images but there is no more logs when I re-enter the plugin page again, so I assume it uses the cache upon further requests, but it's still awfully slow. Maybe it's the resizing itself that takes a lot of time? Is the resized image cached or the original? I've only tested on 7.9.x so far as I recently moved my mai system to that release.

    I'm not sure I'm following your comment wrt the URL I gave in my previous post. This url is something I gather in the plugin through some web services and that I then set as the icon for the next level display menu items in LMS, as I do in my other plugins (I've added the code in previous post)
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

  8. #8
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    2,836
    I was wrong, there is no trace at all of any caching activity by LMS when an image is set to a remote URL for a menu item. So it seems that caching will have to be manual for these as, for an unkown reason, it's hyper slow for the site I'm using. I tried to use ImageProxy but so far I could not get it to work. I was hopping that using getImage and proxiedImage would let me set the URL I want to be proxied (cached) so that the slow penalty only happen once. Is this the right direction and if it is, is there a plugin that I could take model from?

    Thanks

    [edit]: to elaborate a bit more, my uneducated impression after looking at the code was that getImage would do the work of getting the image of the URL provided and cached. Then using proxiedImage I could get the proxied (local) url to give to LMS so that further access to that image would purely be local
    Last edited by philippe_44; Yesterday at 22:07.
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

  9. #9
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,476

    LMS caching menu item image

    Philippe,

    it would be much easier to understand the issue if you shared your code.
    Or answered my question: what URL is the client loading? Is it the one
    you posted earlier? Is it one pre-fixed with mysb.com or something? What
    is your setting in Settings/Advanced/Settings -> image resizing? And
    what client are you testing with anyway?

    That URL is referring to a rather reasonably sized image (69kB). That
    should load just fine. But it's 767x1316px - which is rather large for
    eg. the Radio if it had to resize on its own. Therefore it's really
    important to understand _why_ it is slow (transfer vs. scaling, server
    side resizing vs. client side etc.). Any optimization without knowing
    what you're doing might be a waste of time.

    A custom image proxy would mostly make sense if you had the option to
    eg. download various sizes of the image to reduce the load on the
    connection and resizer. If there's only one image to download, then a
    custom image proxy doesn't add anything but overhead.

    --

    Michael

  10. #10
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    2,836
    Quote Originally Posted by mherger View Post
    Philippe,

    it would be much easier to understand the issue if you shared your code.
    Or answered my question: what URL is the client loading? Is it the one
    you posted earlier? Is it one pre-fixed with mysb.com or something? What
    is your setting in Settings/Advanced/Settings -> image resizing? And
    what client are you testing with anyway?

    That URL is referring to a rather reasonably sized image (69kB). That
    should load just fine. But it's 767x1316px - which is rather large for
    eg. the Radio if it had to resize on its own. Therefore it's really
    important to understand _why_ it is slow (transfer vs. scaling, server
    side resizing vs. client side etc.). Any optimization without knowing
    what you're doing might be a waste of time.

    A custom image proxy would mostly make sense if you had the option to
    eg. download various sizes of the image to reduce the load on the
    connection and resizer. If there's only one image to download, then a
    custom image proxy doesn't add anything but overhead.

    --

    Michael
    Yes, sorry - here is the repository with the code: https://github.com/philippe44/LMS-LCI.

    The client is using the webservice api of the LCI site and parsing the JSON content, it creates a 1st menu in LMS with all the available channels (dynamic list). Each channel has a set of associated icons/pictures that I want to display in the LMS menu, like I do in YouTube or Pluzz. Then when selecting the next level, the same process happens again. I don't know where the slowness comes from, if this is resizing or downloading. So I was hopping to do download and then resize to solve this, whatever was the reason.

    The URL in the previous post was just an example of the ~30 channels in 1st level menu (takes me a minute or two to load on a i7 2.6GHz and 60Mbits/sec cable). If it was only one image, I would have it manually part of the plugin, but the number of channels / tracks if of course unknown/dynamic although my observation is that 1/they don't change often and 2/same image is used many times - but that's not under my control

    For each channel/track found there is a choice of various resolution & dpi picture and I'm trying to select the lowest one

    [edit]: so sorry ... I did not realize that image proxing / resizing was done by mysb.com, I thought it was done locally. Changing the parameter to local resizing cured the problem in the LMS menu.
    Last edited by philippe_44; Yesterday at 22:57.
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •