The Media Center Sandbox

Resources and discussion for developing experiences in the Windows Media Center platform.
Welcome to The Media Center Sandbox Sign in | Join | Help
in Search

Image file display problem

Last post 08-11-2009, 12:14 AM by MrBungle. 14 replies.
Sort Posts: Previous Next
  •  06-09-2009, 10:01 AM 9256

    Image file display problem

    I'm having trouble displaying some jpg files that are being supplied from an http uri.  For some reason some of the images I'm trying to display are being displayed but others are not (always the same files).  All images are viewable if I type the url into a browser and if I donwload them and display them from a local file uri they work.  I've stripped my mcml down to just a basic graphic in a panel so it's not a sizing constraint problem.  It's almost as if there is a corrupt cache or something, but I've no idea whether one exists or where that would be.  To be honest I'm totally out of ideas.  Has anyone seen anything like this before?

    Thanks
    Martin
    http://www.armchairware.com
  •  06-09-2009, 10:56 PM 9259 in reply to 9256

    Re: Image file display problem

    If the image is cached it's going to be cached by name, so try renaming the image to something else (if you haven't got access to the server, download the image and store it somewhere else to check).

    Also, try putting MaximumSize on the graphic just in case it's too large to fit on screen - when something is too big for the available area, MCML just doesn't display it.

    Cheers,
    Andrew
  •  06-10-2009, 2:19 AM 9261 in reply to 9259

    Re: Image file display problem

    Ok, here are a few more details about this problem.

    The following file works fine:

    http://photos-b.ak.fbcdn.net/photos-ak-sf2p/v159/22/43/664495032/n664495032_738889_7206.jpg

    This is simply referenced in a Graphic element as the only child of a Content i.e.

    <Mcml xmlns="http://schemas.microsoft.com/2006/mcml">
    <UI Name="Test">
        <Content>
              <Graphic Content="http://photos-b.ak.fbcdn.net/photos-ak-sf2p/v159/22/43/664495032/n664495032_738889_7206.jpg"/>
        </Content>
    </UI>
    </Mcml>

    However, if I switch the URL to this, for example:

    http://photos-b.ak.fbcdn.net/hphotos-ak-snc1/hs085.snc1/4588_182096855566_695735566_6961209_7820026_n.jpg

    it doesn't work.

    Both files can be viewed in IE7.  Although for some reason only the first is cached in the Temporary Internet Files folder (C:\Users\<UserName>\AppData\Local\Microsoft\Windows\Temporary Internet Files) which maybe indicative of the problem.

    Having said that I can get the 2nd file to cache if I launch the link from a cell in an Excel spreadsheet.  And perhaps as expected once it is cached it then works fine in Media Center.

    So the problems as I see it are that for the 2nd URL:

    1. The Url doesn't work in a Graphic unless it has been previosuly cached.
    2. The resource does not get cached by IE7 if the URL is entered directly in the the address bar or by referencing it directly in Graphic element in Media Center.
    3. For some reason it does get cached if it is launched in IE from a link embedded in an Excel spreasheet.

    It'd be good to know if anyone can replicate this.

    I'm not very knowledgeable about the IE cache.  Does this seem weird?  Is it a known bug?  Any help would be greatly appreciated.



    http://www.armchairware.com
  •  06-10-2009, 4:16 AM 9262 in reply to 9261

    Re: Image file display problem

    This seems to be a problem with the HTTP cache header in the response from the web server that is hosting the resource.  I've had a look at the header in Fiddler and there are consistent differences between those files that seem to cache correctly and those that don't.  I'm no expert in this and unfortunately the webservers I am using are not under my control so I am unlikely to be able to affect any changes on them to get this to work.  So I think the only option left is to try to download the file locally and cache it myself using something like System.Net.WebClient.

    Quite why the problematic files are viewable in IE7 and not in Media Center is still a bit of a mystery.  Is it possible that Media Center uses the local IE cached file in the Graphic view item rather than the stream returned in the HTTP response?

    http://www.armchairware.com
  •  06-11-2009, 2:25 PM 9263 in reply to 9262

    Re: Image file display problem

    I am no expert in ASP.NET, but what if I write your MCML as an ASP.NET script and turn off caching?

    I think the command is Response.Cache.SetCacheability(HttpCacheability.NoCache);

     


    This posting is provided "AS IS" with no warranties, and confers no rights.

    David Teo
    SDET
    Microsoft Corporation
  •  06-12-2009, 1:14 AM 9265 in reply to 9263

    Re: Image file display problem

    Sorry David, I'm not quite sure what you are suggesting.  The MCML files I am using are local resources in my assembly and I have no control over the web servers providing the images resources that are being displayed (or not) by the MCML Graphic view items.

    Further my my idea of using the the WebClient class to download the files locally into my own cache before using them in the Graphic view items it seems that this is also problematic.  Some of the HTTP responses containing the image files are generating a WebException when I call the Download method on the WebClient caused by improperly formed headers containing either single line feed or carriage return characters (these are not necessarily the same images that I have had problems displaying because of their caching problems).  The documented solution for this is to use the UseUnsafeHeaderParsing attribute in the app.config file as below:

    <configuration>
      <system.net>
        <settings>
          <httpWebRequest useUnsafeHeaderParsing="true" />
        </settings>
      </system.net>
    </configuration>

    This however is not straight forward in a Media Center add-in assembly because, since the assembly is loaded into ehexthost.exe, we cannot reliably/should not change the app.config used by the hosting process.  So then the question is 'can the config of the host processes default AppDomain be modified at runtime?'.  I have tried this but failed for the system.net configuration elements and have had to resort to creating a new AppDomain with a custom config loaded into containing the above in which I make the WebClient Download method calls.  This does seem to be working but is perhaps not most obvious solution. I hope this is useful to anyone else that may experience similar problems when trying to display Internet sourced images.  Obviously if I've made this far too complex and there is a much simpler solution I'd be glad to hear about it.

    http://www.armchairware.com
  •  06-12-2009, 2:51 PM 9267 in reply to 9265

    Re: Image file display problem

    My bad, I misunderstood and somehow thought you were using codeless MCML.

    The Graphic element does allow you to specify AcquiringImage and ErrorImage.  I know that is not the solution to the problem you are facing but it may help out visually.

    Also have you checked to see if this maybe the result of a web server configuration issue?  In other words, have you checked it against another web server?


    This posting is provided "AS IS" with no warranties, and confers no rights.

    David Teo
    SDET
    Microsoft Corporation
  •  06-15-2009, 1:38 AM 9270 in reply to 9267

    Re: Image file display problem

    I'm sure it is to do with a web server config issue, but I have no control over the web servers supplying the content (they are Facebook Content Delivery Network servers for photos) so I have to be able to deal with them the way they are.

    The problem is that if the HTTP response header for the photo doesn't specify that the image should be cached then Media Center does not display the image.  It would be good to know if you can confirm this using the links in the earlier post on this thread.  It does seem that this is a bug as IE can display the images despite the header.

    http://www.armchairware.com
  •  06-15-2009, 11:38 AM 9271 in reply to 9270

    Re: Image file display problem

    I will relay this to the feature team. Thanks.

    Does this have to do with the Facebook server itself having content protection for non-browser clients?

    Can you download this image using their API first?
    This posting is provided "AS IS" with no warranties, and confers no rights.

    David Teo
    SDET
    Microsoft Corporation
  •  06-16-2009, 2:39 AM 9274 in reply to 9271

    Re: Image file display problem

    The images can be downloaded using the Facebook API via System.Net.WebClient (which as mentioned above sometimes requires UseUnsafeHeaderParsing) so I don't believe this is a content protection issue.

    http://www.armchairware.com
  •  06-18-2009, 3:56 PM 9279 in reply to 9274

    Re: Image file display problem

    At this point, I would have to say, it is not a supported scenario. Turning off HTTP parsing validation errors is not something we would test or support.
    This posting is provided "AS IS" with no warranties, and confers no rights.

    David Teo
    SDET
    Microsoft Corporation
  •  06-19-2009, 1:44 AM 9280 in reply to 9279

    Re: Image file display problem

    Sure, I can understand that.  The WebClient header parsing problem is because of the configuration of the Facebook content delivery network webservers, which obviously I have no control over, and therefore need to deal with it if I want to download and display the images.

    However, just to be clear, I only need to download the images myself because Media Center can't display some of the image files in Graphic view items directly using the Facebook supplied http URL for the image files (possibly related to the caching header information).  It's this problem that it would be great to get confirmed as a problem and ideally fixed if it is.

    http://www.armchairware.com
  •  06-19-2009, 3:30 PM 9282 in reply to 9280

    Re: Image file display problem

    From what I understand, Media Center can't display the image files in Graphic view items directly using the Facebook supplied http URL because there is a configuration issue with Facebook webservers.

    It is not an actual Media Center issue and yes, perhaps IE is more resilient to http parsing validation errors given its role. I have talked to the feature team and unfortunately, this falls outside the scope of what we want to support. Unless you can show that this repros even on a well behaved web server.
    This posting is provided "AS IS" with no warranties, and confers no rights.

    David Teo
    SDET
    Microsoft Corporation
  •  06-19-2009, 4:43 PM 9283 in reply to 9282

    Re: Image file display problem

    FWIW, I've seen similar issues with images being served from a 'stock' Windows Server 2008 IIS installation. Never looked into it in detail as I only used that server for local testing though.
  •  08-11-2009, 12:14 AM 9313 in reply to 9283

    Re: Image file display problem

    I had an almost identical problem that i reported here. I couldn't get the image to display in via MCML from an Axis camera unless I first requested the image in IE7. I never figured it out...
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems