It's always interesting to spend time poking through the application bundle for newly released Mac OS X software. Inside the bundle are all sorts of files and resources that can sometimes give you insight as to what is going on with development. Today, Ars had a chance to dive into Safari 4 and explore some features that were hidden away from surface inspection.

To look inside any Macintosh application bundle, select it in the Applications folder, right click and choose Show Package Contents from the pop-up. A new Finder browser window will open, revealing the bundle contents. Choose View > as Columns (Command-3) for the easiest browsing experience.

Inside the bundle are three intriguing items, all new to Safari 4: a code signature folder, a Safari webpage preview fetcher, and a WebApplicationCore bundle. Of these items, the signature folder and the bundle are not remarkable in any real way other than showing the growth of the Safari application.

Contents of the Safari 4 Application Bundle

According to Apple's Safari features page, Safari 4 offers support for many next-generation Internet standards including offline databases for standalone Web applications. The new WebApplicationCore bundle appears to provide the core support for these Web applications. Strings in the bundle suggest little more functionality than loading the application, running it, linking to other Web apps, and quitting.

The _CodeSignature folder is one of the first any of us at Ars has noticed for an application shipped directly from Apple. Application signing has been around a long time and is used widely by third-party developers. We've seen Apple sign frameworks before. We've seen Apple sign executables before. But this is the first time we've seen Apple signing general application material. This kind of signing assures the integrity of the application bundle, including images, property lists, and so forth. (Test for yourself. Issue ls /Applications/*/Contents/_CodeSignature or locate _CodeSignature from the CLI.)

What came as a small surprise to us was the third and last item: the Safari Webpage Preview Fetcher. It's a standalone utility that is called from Safari whenever users enter the Top Pages browser. We were able to track the calls to this utility by running dtrace. Sure enough, the preview fetcher was tied to Top Pages and was called as often as not when the Top Pages browser was activated.

Catching preview calls through dtrace

A little investigation showed us that the utility updates a preview cache located in /var/folders. The exact location will likely vary. Issue cd /var/folders/*/*/-Caches-/com.apple.safari from the command line to locate the Safari cache folder, which will own a Webpage Previews subfolder. The actual call to the fetcher looks something like this:

3011 ?? 0:00.02 /Applications/Safari 3.app/Contents/Safari Webpage Preview Fetcher /var/folders/Xo/XoLxWUlSFtSplCoUpBV7DE+++TI/-Caches-/com.apple.Safari/Webpage Previews/Incoming

When run, the utility grabs high (PNG) and low (JPG) previews of the webpage and adds them to the cache folder.

So why does Safari do this? Why call an embedded utility? This question led to a lively behind-the-scenes discussion at the Orbiting HQ. In this, as in many things, John Siracusa provided the greatest insight. Perhaps, he suggested, this is a vote of no confidence in Mac OS X's concurrency frameworks, particularly when used in conjunction with a big library like WebKit. Some developers complain about NSOperationQueue and threading in general, as Apple's concurrency libraries are not really where they should be just yet. (Rogue Amoeba, greatly disappointed with Apple's class, offers an open-source replacement for NSOperationQueue.) Alternatively, he offered that maybe this part of Safari just had to be done in a hurry and will be integrated into the main application some time in the future.

Nothing we found today really shook our world or indicated an unexpected new direction for Apple. At the same time, it's always intriguing to see what is new, what has changed, and where each application release takes us. If you find anything new in Safari that we've missed, please share with us in the comments.