RSS 2.0 Feed
The Screensaver Ate My Memory...

A couple of months ago, I promised that I would file a report on our new Acer iDea 510 Media Center. Our old Evesham box was starting to fail, and - after the disappointing episode with the Sony Media Center - I was hoping that the new one would be all that the Acer Web site promised. Of course, a recommendation from Dave, who runs one of these, helped; and I have to say that the Acer certainly is a whole generation ahead of the competition I've seen.

Acer iDea 510 Media Center

First off, it actually looks like a consumer device. OK, so it's a bit flashy in design terms but the matrix display that shows the current task or program, together with "Recording" indicators, volume, and status lights, is actually quite useful. And, while I haven't needed to use the front panel navigation controls (play, stop, skip, etc.), they are neatly implemented and a good idea.

Installing the box was also a revelation. Unlike most other machines, there is no useless "demo" software installed that you end up having to get rid of, no programs in the Startup folder or set in the Registry to auto-start that will soak up memory and yet never get used, and only the relevant and necessary icons on the Desktop. You simply plug in, hit the big start button on the front panel, follow the Windows setup prompts, and it all just works.

Nice touches elsewhere in that it has two separate hard drives; with all the O/S and stuff on one, and the second configured as the "Recorded TV" location. Therefore, when you back up or image the drive, you don't end up with Gigs of TV programs to back up. In fact, the only things I had to change were the BIOS settings to get it to auto-boot after a mains failure (when the UPS runs out of steam), and a few configuration changes to get it to read the music and videos from the server in the garage.

It also helps to maintain my "green" intentions, by going into standby and then hibernating when not in use. Yet it invariably wakes up to fetch the guide data, record programs, or when you hit the front panel button. It's just possible that I might even recommend this machine to my less technical friends, as it is probably as close as you get to a consumer device while still running Windows Media Center.

The only minor complaints I have are the that intra-red remote sensor is rather choosy about the accuracy of your aim, and perhaps the video connections could have been more useful. On the first of these issues, my wife has a habit of waving the remote wildly at any and every device, cupboard, screen, ornament, and table lamp when attempting to change channels or adjust the sound level. However, I solved this problem with a second cheap remote handset and wide view IR receiver that plugs into a USB socket.

The second problem is that the SCART output seems somewhat unreliable or selective about when it works. I could get nothing out of it and Dave said he has similar problems, though for him it "just started working after a while". Thankfully there is a VGA socket that gives a quality picture at the low screen resolution of our rather aging plasma. Related to this, the Acer cannot generate a picture at the rather weird native resolution of our screen, so the Windows desktop is a bit fuzzy. However, the translated TV picture and photos when using 1360 x 765 are perfect, and everyone looks slimmer and has approximately the correct length nose.

Talking of going green, I recently had an interesting (in a geeky programmer sense) encounter with caching issues, which just reinforced my opinion that good caching is in the eye of the beholder. Or rather, getting caching right is much more difficult than you might assume, and assumptions can easily cause problems.

The starter for this episode was the search for a screensaver for the new Media Center that could display pictures, whilst still allowing the machine to hibernate and save a few precious amps where possible (I told my wife it would soon pay for itself in saved electricity, though that was perhaps a somewhat optimistic assertion). As the old Media Center never went to sleep, or never restarted if it did, this wasn't a problem before. What I now wanted was a screensaver that would run for a preset time showing a selection of our digital photos, then gracefully stop, dim the screen, and allow the machine to hibernate.

Of course, I couldn't find anything remotely like this, even to buy. So I downloaded a sample written as a demonstration of the .NET 2.0 drawing capabilities, and proceeded to hack it to get what I wanted. It was easy enough to change the code so it had better configuration options, and stopped after a preset time. The code to display the pictures runs on a background thread using a While True ... End While loop. I simply added a comparison of the current time against the projected end time (saved in the screensaver routine), so the thread terminates when its time is up.

So far no problem. There were other tweaks required to make it work better alongside Media Center, such as detecting Activated and Deactivate events, forcing reactivation of the main window (the photo collage) at regular intervals, and making sure the program terminated after a set time when deactivated. Media Center regularly grabs the focus when events such as recordings starting or ending occur, even when the screensaver window is set as "Topmost".

However, in testing, it seemed that the screensaver was crucifying the O/S to the extent that it took up to 30 seconds for the screen to show Media Center and respond to commands when the screensaver terminated. I spent many unhappy hours looking at threading issues and activation events trying to solve the problem, until at last I did some memory usage measurements. At this point I discovered that, after 20 minutes, the screensaver had eaten up over 1 GB of memory and swap file!

How? Well, the code works as you would expect by iterating through all the specified picture folders building a list of pictures to display, then shuffles the list and iterates through it displaying each one in turn. However, the code uses a generic list of a custom class to store the image data for each picture. Initially, the data is just the image file path and name. However, as it displays each picture, the code generates the resized image for display from the original, and stores both as bitmaps within the custom image data class.

This is obviously aimed at minimizing disk accesses and processor load, because - when the code has shown all the available pictures - it reshuffles the list and then iterates through it all over again, repeating the process until it detects a key-press or mouse movement. That's fine if you only have a few pictures, but our collection of new and scanned old photos stretches to over 3000 images, and many are 3072 x 2304 pixels and 1.4 MB. It's no wonder the system was struggling.

A quick addition to the code to stop it caching the images, and the screensaver now runs reliably and stops instantaneously on demand. And Media Center works fine straight away. It just goes to show how you can't make assumptions on the effect caching will have on performance, especially when you don't know the target system or the data handling requirements.

And finally, to end this month, a quick note on a Web site I found by accident the other day while looking for a Web site stats program. I'm just back from the ASP.NET Connections conference in Las Vegas (where, as far as I could see, a great time was had by all). I spent much of the time presenting and discussing the growing compatibility and accessibility issues on the Web with Flash, AJAX, Silverlight, etc. And then I found this:

Internet Explorer not compatible

So much for the Web being a universal information system! I thought this kind of warning had long ago disappeared... what does the site do that's "not compatible with Internet Explorer", and how compatible is it with other (specialist and accessible) user agents?

Email: feedback@daveandal.net         Privacy and Acceptable Use Policy