When switching between multiple Photoshop documents, the PerLayerMetadata example panel shows the metadata of the document that is being switched away from, not the newly selected document.
In CS5, the panel receives the select event, then the panel does its thing, then Photoshop updates activeDocument to point to the newly selected file.
In CS4, Photoshop activeDocument is pointing to the newly selected file before the panel acts on the event.
Something similar happens with a panel I have created. I have found two ways to fix it.
One is to add app.refresh() to the event handler. That works fine but slows down the panel. And I could not find a way to tell what was being selected so I could add the refresh to just the select document event.
So instead I just added a button to the panel to manually update the panel info.