Wednesday, July 27, 2011

Pandora Moves to HTML5

Screenshot showing link above normal Pandora player with a link to preview the all NEW Pandora website
I love new things just as much as the next person. So I have to admit that I was intrigued when I saw the little banner above pop up above the normal Pandora music player in my browser.

I clicked on the link to change to the new Pandora layout and was immediately greated with a splash screen, styled similarly to the Pandora mobile apps. I was immediatly struck by the better use of space that the new Pandora had, and how it seemed somehow more responsive. Everything seemed to be rendering so much better/faster with this new version, and it just seemed to integrate better with the browser. I was able to resize the player, and it made much better use of the page space than the previous version did.

After playing with the new interface for a bit, I had a suspicion that this might not even be a Flash app anymore. Sure enough, the task list in Google Chrome showed that the Flash Plugin wasn't running!

After discovering this, I had to compare the old player vs. the new player in terms of CPU and memory use. Here are the results of my totally unscientific survey of performance of the old, Flash based Pandora vs. the new HTML5 based Pandora. Before the test, I killed all non-essential apps, and restarted the browser between tests.

System: Windows 7 64-bit, AMD Phenom II X4 955 @ 3.2 GHz, 8G of memory
Browser: Google Chrome 14.0.835.15

Flash Based Pandora
Screenshot showing Flash Plugin in the Google Chrome task list using about 100 megabytes of memory and 8 percent of the CPU
Foreground:
90-120MB of memory
6-9% CPU when playing
4-6% CPU when paused

Minimized:
90-120MB of memory
1-4% CPU when playing
0% CPU when paused

HTML5 Pandora
Screenshot showing the HTML5 based Pandora using 71 megabytes of memory, and 1 percent of the CPU
Foreground:
70-80MB of memory
1% CPU playing (Max 3)
0% CPU paused

Minimized:
60-65MB of memory
1% CPU playing (Max 3)
0% CPU paused

Based on my development experience way back in the early days of Windows (C, WinMain's, and Message Pumps, oh my!), I knew that for a variety of reasons, a minimized app would often take less resources than a foreground app. That's the reason I tested both versions both in normal windows, and in minimized form.

The Flash app used more resources on average (I sampled the numbers over a minute or so) than the HTML 5 app in all ways. Interestingly, running the old Pandora minimized did lower CPU utilization quite a bit. Running the new Pandora minimized seemed mostly to only release some memory.

One thing to be careful with is that we can't make any assumptions about HTML5 being more efficient than Flash overall with this simple test. The developers who created the new Pandora app might have made better design decisions with the new version based on what they learned from the first version. Possibly re-writing the app in Flash would have resulted in similar performance gains.

I think what is interesting is that Pandora, a major online service provider, has decided that HTML5 was important enough for their strategy that they made a switch. There are other high profile cases of switching (Scribd) or at least experimentation (YouTube). One could probably blame Steve Job's stonewalling of Flash as a major contributor to this shift in thinking.

Having worked on a large Flash application recently, I would say that the current limitation with HTML5 is tooling. Flash has a very efficient model for putting apps together (their compiler could use some work, though), that no HTML tooling I've seen so far can match.

Also interesting is that Adobe itself is investing in providing HTML5 tooling. It's a smart hedge for them, and makes sense given their history with DreamWeaver tooling for HTML 4 development. Hopefully Edge will continue to develop into a fully fledged HTML5 application development IDE.

Friday, June 03, 2011

Cabbage Destroyed

All of the cabbage that I planted was destroyed by some kind of caterpillar. I didn't notice anything at first except for a few plants that had been gnawed around the edges. Then when I started inspecting the interior of the plants to see if heads were forming, I noticed all kinds of little green caterpillars chewing away at the tiny, forming heads of cabbage.

It kills me because they seemed to be doing so well up to that point. I ended up having to pull all the plants up, and compost them.

I'm going to try planting some summer crops now, and spray them with an insecticidal soap to hopefully prevent this from happening again.

Not to be beaten, I've added another bed, and I'm going to try some squash, tomatoes, peppers, green beans, and maybe another vegetable or two.

Sunday, May 08, 2011

Type Safe Criteria API for Hibernate

I've started a library for a type-safe criteria API for Hibernate called SafeCriteria.

I've always been bothered by the fact that the Criteria API always requires one to use text strings for the property names. Strings aren't checked by the compiler, so they can hide errors in your code until runtime, which is way too late.

In short, SafeCriteria allows you to query via "showing" the API what properties you want via the getter methods for that property. The great thing is that the getter methods are checked by the compiler so you at least get some help there, and if you need to refactor a property getter the refactoring tools of your IDE will help you catch these references as well.

I also have some ideas for handling class aliases better than with remembering strings in your property names, but that is coming after the basics are working properly.

Maybe I'm just scratching my own itch here, but someone else might have the same itch. If anything, I'll at least get better at writing DSLs. Anyway, have a look at the project on BitBucket.

Monday, April 11, 2011

Thinning the Vegetables



Today, I had to thin out the cabbage as all the sprouts would never have enough room in the bed to grow. This process was quite difficult for me because I had to kill some perfectly healthy sprouts. It was for the benefit of the remaining cabbages, but it was still hard for me to choose. The bed looks a lot more sparse now. I hope the remaining plants get bigger soon.




On the plus side, the small thinnings from the cabbage are tasty enough for even my youngest to eat with some ranch dressing. I think I'll take a salad with them for lunch at work tommorow.


Today's conditions: Partly Cloudy, High of 84°, with late night thunderstorms.

Saturday, April 02, 2011

Dell Streak Wouldn't Connect to Cell Network

I had a bit of a scare this morning with my phone. I have a Dell Streak running Android 2.2 and for some reason this morning when I powered it up, it wouldn't connect to the cellular network. I had grey bars with an X next to them in the status bar, and I couldn't make calls, or get on the internet except for wifi.

Going into Settings -> Wireless & networks , I noticed that "Airplane mode" was checked. I figured maybe I set that at some point and forgot, so I tried to uncheck it. The button would stay greyed out for a while, and if I left the settings page and came back, it was still checked.

I tried pulling the battery, SIM card, SD card, and then putting the battery back into to restart. Still no cell connection. I pulled the battery out again, put everything back in, but still there was no cell connection.

Finally, I searched some forums and found that people have this problem for various reasons. Suggestions ranged from the procedure I tried to a full factory wipe and re-install! I didn't want to wipe everything, so I tried going to Settings -> About Phone -> System updates to see if there was some Android update out there. Of course, there seemed to be no new updates out there. Going to the bottom of the About Phone list showed that I was running the 12821 build of Android 2.2 from Dell. Based on my searches, it seems like that is the latest version of the phone OS as of this post.

A little more digging in the forums found a direct link for the 12821 build of the OS at http://mobileupdate.dell.com/?version=GAUSB1A110100. This version string at the end of my URL doesn't match my baseband version, but I figured it would be worth a shot. After navigating to this link in the phone browser, the phone downloaded the 12821 build, I then tapped the notification that the update had downloaded, and my phone proceeded to try to install the update.

I'm not sure if anything really was updated since I was already at the 12821 build, but after the phone rebooted I saw that the cellular indicator was showing full blue bars again, and the phone now was no longer in Airplane mode.

Monday, March 28, 2011

Garden at 9 days

In an attempt to keep myself focused on my garden this year, I'm going to try and keep a log of what I'm doing and the results I'm seeing. Hopefully this will also help guilt me into making sure that I keep checking up on the garden and taking care of it.

Well, we decided to move our raised beds up to a location that gets better sunlight as our vegetables last year just didn't get enough. All in all, it took me about 3 weekends to get the old bed moved up to the hill, leveled, and then build a second bed for planting. We ran out of dirt from cutting into the hill as the hill is a pretty steep one. I ended up putting in some old rubber mulch as a fill under the front bed. Therese and the kids helped me at various points, and I think the results are pretty good.

We're using the same method as last year from the Square Foot Gardening book, although I couldn't get the same vermiculite we used last year. I had to get the bigger, pearl-ized kind. I did find some nice, all vegetable compost called "Foothills" which I combined with some good old fashioned composted cow manure. Lots of changes this year, and hopefully will result in a good crop.

Close up view of a red cabbage sproutIt's been raining the past few days, and I haven't been able to get out to check on the beds much. Today I just couldn't stand it any more, so I went out and took a look. I was pleasantly surprised to find almost of my seeds have spouted. The lettuce and red and green cabbage sprouts look a bit like clover to me right now, and the spinach is just starting to peek through. The green onions apparently think it is a little too cold right now, so they haven't done much yet.

Planting bed showing some sprouts and dig marks from squirrelsIn the back bed, the squirrels have been digging around in the soil, so some of of the seeds have been disturbed. That's why I always follow my mom's advice which she got from my great grandmother on my mother's side. Granny Kate always used to say that when you plant seeds you plant one for you, one for the animals and bugs, and one for the Lord.

Today's conditions: Cloudy, High of 53°, with showers off and on.

Friday, December 17, 2010

SQL Server "no count", and Hibernate StaleStateException

Recently an application my company wrote had suddenly stopped working. We were getting an exception from Hibernate in some maintenance tasks we were doing on server startup. The exception string was: org.hibernate.StaleStateException: Unexpected row count: 0; expected: 1

I wondered how this could even be possible since no one was in the DB at the time the server was starting up. The person who reported this error said it was only happening on this one instance of MS SQL server, and no where else.

So I proceeded to debug remotely from my workstation to the server instance that failing. I noticed that the message on the StaleStateException was that the number of updated rows "0" did not match the expected row count of "1". This was even more confounding to me as I could even see that the row existed in the database. Plus, Hibernate would re-inserted the row if I deleted it, and yet I would _still_ get the StaleStateException.

I should have listened to the person who reported the problem more closely and realized that this was a "server" related issue, and I might have saved myself some time.

I finally got around to checking the configuration of the DB server instance that was exhibiting this problem, and I noticed that someone had turned on "no count" as a default connection setting. Setting "no count" basically tells SQL server not to report back how many rows were affected by the last operation executed. Of course, this is a big problem for Hibernate which uses those row counts to determine if an update was unsuccessful so that it can try an insert on a session.saveOrUpdate() call.

You can find this "no count" setting by going to SQL Server Manager, right clicking on the DB Server instance you have registered in the Object Explorer, and selecting "Properties". Next, select the Connections page, and look in the "Default connection options" list for the "no count" setting. It must be unchecked for Hibernate to function properly.

There are of course lots of other reasons you can see this error with Hibernate, but this is certainly one I hadn't encountered before.