Wednesday, September 15, 2010

Finally! Apple Embraces A Standard for Metadata in PDFs

I draw your attention to the header file CGPDFContext.h in the iOS 4 SDK:

void CGPDFContextAddDocumentMetadata
(CGContextRef context, CFDataRef metadata) CG_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_0);


The iOS 4 SDK has been out for several months but I hadn't noticed this change until today. Not that I have any use for it today on iOS, it's on the Mac where it is crucially needed.

Starting with Mac OS X 10.7, developers will be able to embed arbitrary XML data in the PDFs they can generate with Apple's APIs. [Update: I guess there is no actual requirement of XML based on just the API. I'd recommend standardizing on XML though.] They have decided to use the method advocated by Adobe in which a metadata stream object with a compressed XML payload is inserted into a PDF (Apple does the compression for you, you just have to provide a block of XML data). This is a good way of doing it, but more importantly, it is a simple and standard way of doing it. I would have preferred having an additional vendor tag where I could mark the metadata with a "com.genhelp.mydrawingapp" identifier, but that is not crucial; I can get that data from the XML.

Why is this Important?

As I've explained several times before, on the Mac we used to have this feature which I will call Round Trip Editing, wherein a user could make a drawing in one application, copy and paste the drawing into another application, and then later copy and paste back into the original application, and still be able to edit the drawing. Generations of Mac users relied on this feature to go from applications like ChemDraw into PowerPoint and back again.

This feature has been lost as applications transition from using the archaic PICT clipboard flavor to the modern and beautiful PDF clipboard flavor. There was no direct way to embed large data in Apple generated PDFs, and thus developers were left on their own to munge the format if they dared. And, with no standard or expectation of data embedding, applications did not bother to preserve the original PDF resulting in data loss.

Getting round trip editing working again has required 3 steps. Apple has had to provide an API for data embedding. Content generating applications have to be modified to use that API. Office applications have to be modified to return original PDFs to the clipboard when selecting a single image. With Mac OS X 10.7, step one will be here; about 4 OS versions tardy.


BTW Here is how to call it:

CFDataRef MakeAPDF(CFDataRef someXML)
{

CGRect mediaRect = CGRectMake(0, 0, 400, 600);
// use your own rect instead

CFMutableDataRef result = CFDataCreateMutable(kCFAllocatorDefault, 0);
CGDataConsumerRef PDFDataConsumer = CGDataConsumerCreateWithCFData(result);

// mark the PDF as coming from your program
CFMutableDictionaryRef auxInfo = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, NULL, NULL);
CFDictionaryAddValue(auxInfo, kCGPDFContextCreator, CFSTR("Your Programs Name"));
CFDictionaryRef auxillaryInformation = CFDictionaryCreateCopy(kCFAllocatorDefault, auxInfo);
CFRelease(auxInfo);

// create a context to draw into
CGContextRef graphicContext = CGPDFContextCreate(PDFDataConsumer, &mediaRect, auxillaryInformation);
CFRelease(auxillaryInformation);
CGDataConsumerRelease(PDFDataConsumer);

// actually make the call to embed your XML
CGPDFContextAddDocumentMetadata(graphicContext, metaData);

CGContextBeginPage(graphicContext, &mediaRect);
// do your drawing, like this grey rectangle
CGContextSetGrayFillColor(graphicContext, 0.5, 0.5);
CGContextAddRect(graphicContext, mediaRect);
CGContextFillPath(graphicContext);
// end your drawing

CGContextEndPage(graphicContext);
CGContextFlush(graphicContext);
CGPDFContextClose(graphicContext);
return result;

}

And here's how to get the data back. Check that the XML is yours instead of some other program's.
CFDataRef ExtractMetaDataFromPDFData(CFDataRef pdf)
{

CFDataRef result = 0;

CFRetain(pdf);
const UInt8 * pdfData = CFDataGetBytePtr(pdf);
CFIndex pdfDataLength = CFDataGetLength(pdf);
CGDataProviderRef dataProvider = CGDataProviderCreateWithData(kCFAllocatorDefault, pdfData, pdfDataLength, NULL);
CGPDFDocumentRef pdfDocument = CGPDFDocumentCreateWithProvider(dataProvider);
CGDataProviderRelease(dataProvider);

if(pdfDocument)
{
CGPDFDictionaryRef docDict = CGPDFDocumentGetCatalog(pdfDocument);
CGPDFStreamRef metastream = 0;
if(CGPDFDictionaryGetStream(docDict,"Metadata", &metastream))
{
CGPDFDataFormat format = CGPDFDataFormatRaw;
CFDataRef streamData = CGPDFStreamCopyData(metastream, &format);
if(streamData)
{
if(format == CGPDFDataFormatRaw)
{
result = streamData;
CFRetain(result);
}
}
}
CGPDFDocumentRelease(pdfDocument);
}
CFRelease(pdf);

return result; // check to see if this is your XML
//remember to release result when done

}

Monday, August 23, 2010

The Three Numbers in Computer Programming

When I was working at a small company in Illinois, Vysis, my team had an architect named Ian Poole who taught me many things, and one of them was the simple fact that there are only three numbers in software design: zero, one and every. By this he meant, you can support the case where there are zero copies of an entity, one copy of an entity or an arbitrary number.

I ran into this problem when revamping my iPhone app,  Signal GH, to monitor antenna signal strength from an HDHomerun. I had mistakenly written it to handle two tuners in a single device. The code was littered to references to the "yellow" tuner and the "cyan" tuner, as that was the colors of their graphs. Well, Silicon Dust came out with a version with a single tuner, which sort of shot me in the foot. And then I bought that device which gave me three tuners on my network. I had a painful time backing out my bad design choice in favor of a more arbitrary number (I did limit it to keeping track of 8 tuners, but that number is kept in only one place and could be changed in a few minutes.)

The new version will be out shortly, fighting off one last bug.

Thursday, July 08, 2010

Wednesday, July 07, 2010

iPhone 4 improves on audio output isolation

I often hook up my iPhone to my car stereo and listen to podcasts while driving. I tend to drive with one earphone in place so I can click to pause or answer phone calls. In the past, whenever I turned off my car's stereo, I could still hear a indistinct and annoying noise coming through my headphones even though the sound was supposed to be going out the line level output in the phone's dock connector. Now, with the iPhone 4, it's quiet. Just another little improvement.

Tuesday, June 01, 2010

On Fixing the Personal Computer's Original Sin

A conversation with an old friend the other day brought up the limited file handling ability of the iPad. Apple really doesn't want you to deal with files as such on the iPad. When the original iPod came out, there was a lot of criticism about not allowing the user to maintain their own MP3 file trees and drag and drop onto the device as competing products allowed; and Apple kept it that way. These are two examples of rectifying one of the original sins of the computer: forcing users to deal in an ad hoc manner with individual documents as files.

Oh, you might say that it is freedom itself to be responsible for filing away today's expense report as a spreadsheet inside of a folder with 500 not quite identical others, or knowing where each of 10 versions of Margaritaville is located, and which is your favorite. To the contrary, it is just another example of the user being trapped by a lack of imagination on the software architect's part into doing something the computer should be much better at doing.

Or you might say that the individual file is a natural unit of information, like the Boolean bit; and that is not true, the computer file was invented by a man (unless it was invented by Grace Hopper, which I doubt); and computers could have evolved with some other mechanism; perhaps mimicking the human brain which I don't believe uses files.

If I were a bench chemist, and every day I drew some new variant of a steroid, where would I want my drawings, in individual proprietary documents, or in a database giving my work structure and context? Pretty obviously in a database. It creeps up on us, the slow flood of documents; the more organized among us can keep it together through ever deepening trees of folders and files, but eventually individual files in folders becomes unmanageable. I've been using a computer for 25 years, I look forward to at least another 40 years of use. There is no way I will be able to productively keep track of all my creations over that time in a tree structure. As it is, anything older than 5 years might as well be non-existent.

So the operating system vendors introduce search, and we get by like our computers are mini-Googles; as long as we can remember some key phrase we can find it; except when words fail us, or the document can't be parsed by the indexer.

And the cloud beckons. Anyone who thinks the cloud is just a well sorted FTP site, doesn't understand. The iPad is right now at one of those points where Apple can see but cannot provide, or even enunciate the ultimate solution, but does not want users to get into the habit of using individual files for their document needs; so we get the hacky solutions that will be cast aside the moment anything remotely elegant is provided. And I don't know what this solution is either. People have been trying to improve upon the file based system for years; the Newton didn't have files, BeOS had some sort of database file system. OpenDoc tried to get all documents to live together in harmony, etc. And none of these were a market success. Files will not die easily; and you will still have to export to a file for a good long time.

Baring a solution, the point of this entry was just to ask people to keep an open mind about files or the lack of them. Files are not the thing you want; you want to create, edit and view media and documents, and how they are stored in secondary to how quickly you get to them, and how safely they are stored.

Monday, May 24, 2010

Flash's History of Neglect on the Mac - An Example

I turn your attention to this apparently genuine June 18, 2008 forum comment by Tinic Uro, which I will quote:
We have identified the bottleneck in the Flash Player for OSX. Like in the other plugins the culprit is text rendering, in this case rendering using device text. This benchmark spends >50% in a single OSX function: ATSUGetUnjustifiedBounds. You can verify this yourself using Shark. I am working on a change which will cache the results returned by that API to where this call should completely disappear from the performance profile.

If everything turns out well I hope to see that change in future release. Some new numbers on my Mac Pro (note that these represent numbers which can change at any time if we decide to do things differently):

Before the change: ~8.5fps
After the change: ~28fps in Safari (~26fps in Firefox)

This speaks volumes about how little platform specific TLC Adobe historically put into the Mac plugin. A performance bottleneck as glaringly obvious as this should never have been seen by a user, much less bedeviled users and Flash developers for years before someone bothered to run Shark, or now days the CPU Sampler Instrument. Adobe must never have tried to optimize on the Mac at all; if I found a common use case where I was spending half my time measuring the same block of text over and over again, I'd joyously jump on the opportunity to make my user's lives easier because I could fix that in an hour. Apparently, Adobe couldn't be bothered to do the right thing until years later, and countless hours were lost by Flash developers trying to coax the Plugin into looking just as smooth on the Mac as it did on Windows.

And now that Apple is the big dog in the mobile application space, it's payback time for all the years of neglect and shoddiness. And with the eyes of the world upon it, Adobe is having to do the actual heavy lifting of getting decent performance and battery life out of a handful of Android phones just to prove Apple wrong. At least something good might come of this.

In the meantime, I've installed Click to Flash on my Mac and gotten iPad like silky smooth performance out of Safari. it is amazing what all those little ads cluttering up the dozens of open pages I tend to accumulate were doing to my poor MacBook.

Friday, May 07, 2010

Will the Next 13" MacBook Pro have an Optical Drive?

I've been following the news about the new MacBook 13" still having a Core 2 Duo when its bigger brothers have i5 and i7s. Apparently this was because there was not room to fit the added NVidia chipset needed to allow GPU switching. If this chipset problem persists, I'm going to bet that Apple removes the optical drive from the 13" MacBook Pro, giving room for the chipset and a bigger battery, and further I'll speculate that they begin selling a little NAS computer that includes: a shareable optical drive, a centralized iTunes server, a Time Machine server, and AppleTV functionality. This mashup of 4 separate products: Time Capsule, AppleTV, MacBook Air optical drive, and the iTunes library functionality makes a lot of sense, and would be billed as an energy efficient and environmentally friendly way to reduce redundancy. And somehow, this will tie into their cloud strategy which will be coming online shortly. And it would probably have enough GPU powered oomph for on the fly re-compression of video for use on iPhones and iPads.

Wednesday, March 24, 2010

Bye Bye Pentium 4 Server

No sooner had I assembled a mini home theater PC for the TV room, but Amazon Vine offered me a Zotac MAG HD-ND01-U which is basically the same thing in a more appliance oriented packaging.

The guts of my original HTPC will now be moving into the house's new Linux/MythTV server: add a large hard drive, a cheap DVD drive and a larger case. This is going to save me a lot of electricity. A Pentium 4 is a pretty poor choice for a lightweight server, and is now draining over $10 of power a month; the new Atom based server should draw less than a third as much energy and maybe less, as I'm hoping the more modern design will have better idle characteristics. I'll save quite a bit of money in the long run in mothballing my old Dell. And the new Atom/Ion motherboard should be fine for serving the occasional file and recording TV shows.

2.0 GHz Pentium 4 + hard drive + external hard drive = 110 W (or so) at idle
Atom N330 + laptop drive + sleeping hard drive = 25 W idle

If I pay a dollar for ever 10W per month then I'm saving around $8 a month or $96 a year, so the added $180 I'm spending will be paid for in 2 years (or in 4 years if I had had to buy a motherboard and RAM). And I'll have a quiet server that isn't annoying me constantly with its fan.

[Update: It's so pleasantly quiet in my laundry room today. Just have to migrate the svn server on the little NAS to the new server and it's going to be so peaceful in the basement.]

Tuesday, March 09, 2010

Holding onto Legacy PCI Cards is Limiting

After the happiness of putting together an NVidia Ion HTPC for the TV room, I've been looking at replacing the Linux server in the laundry room. It's a typical noisy, energy hog of a Pentium 4 Dell, non-gigabit ethernet, with multiple hard drives either inside it or in an external case. I'd like to replace it with a low power, quiet, modern model. I could collapse my MythTV backend, SVN server, and file server, into one box and save on the order of $15/month in electricity. So, I'd like to move to something like:
  • Dual core Intel Atom N300 processor
  • Ion chipset
  • Small SSD boot drive
  • Large (1.5 or 2.0TB) Green Drive
  • 2 GB RAM
  • mini-ITX form factor

The fly in this ointment is that I have a ATSC tuner on a PCI card in the current box (a very reliable PCHDTV 3000), and getting a mini-ITX Ion with a PCI slot is limiting. As far as I can tell, it is limited to one motherboard: the ASUS AT3N7A-I. And anytime I see customer reviews that include such tidbits as "noisy fan" or "uses more energy than other Ion motherboards" I start wishing for other options.

And the other option is to go with another network tuner. I already have one HDHomerun which along with my PCI tuner gives me the capacity to record three simultaneous shows on the rare days when that's a good thing. Replacing the PCI version with another HDHomerun would open up a larger world of Ion or Atom motherboards with more modern card slots. I even see that Silicon Dust has recently released an economy single tuner model which can be had from newegg for $81.97 shipped. And this will keep the new server cooler and quieter, as well as having another tuner Windows Media Center on my wife's computer can access. Win, win, win.

Tuesday, February 23, 2010

Could Apple Transition to Using iPhone Apps as Safari Plugins?

I've been knee deep in trying to keep an old style NPAPI (Netscape) plugin working under Snow Leopard, and believe me it is not easy. And one of the reasons it is not easy is that Apple has used the 64-bit transition to lock down what an NPAPI plugin can do and when it can do it. No longer are we allowed to do things like bring up our own windows, draw whenever we feel like it, create our own timers, track our own mice and generally do things the easy way; we have to live in the browser and follow the browser's rules.
I refer you to the Web Plugin Programming Topics Guide
Beginning in Mac OS X v10.6, on 64-bit-capable computers, Netscape-style plug-ins execute in an out-of-process fashion. This means that each Netscape-style plug-in gets its own process separate from the application process. This design applies to all Netscape-style plug-ins. It does not apply to WebKit plug-ins, nor at present to WebKit-based applications when running in 32-bit mode.)


It goes on to enumerate a large number of new restrictions on how plugins are supposed to operate in their new out of process home. At this point, it becomes pretty hard to justify using a NPAPI style plugin for any but the simplest plugin for Safari; it is just too strangling. So the mind turns to WebKit plugins which are basically Cocoa NSViews with a few limitations and added message handlers. As the quote above says they are not (at present) limited in such a way as Netscape plugins; in this way Apple is nudging people to use WebKit plugins if for no other reason that they allow you to do things that the NPAPI plugin do not.

And here we come to the idea for this posting, it seems as though Apple is interested in locking down and rationalizing Safari plugins. It is also reasonable that at sometime in the future, they will allow plugins for Safari on the iPad. It is also almost a given that those plugins will not be NPAPI style plugins, but will instead be UIView or UIViewController derivatives. And at that point, the question becomes, wouldn't the UIView style plugin with its simpler and more modern object design make a cleaner foundation for plugins for Safari on the Mac? Apple already has an iPhone simulator on the Mac. Of course, there would have to be some extension allowing mouse hovering events.

    Advantages
  • Code sharing between Mac and iPad
  • Plugins are closer in scope to iPhone Apps then full blown Mac apps.
  • At this point most Objective-C programmers are iPhone developers so developer pool would be larger
  • Expand iPhone apps to the Mac
  • iPhone Apps are used to being sandboxed

Anyway, just a thought.

Thursday, February 18, 2010

Inexpensive Ion HTPC

As I want to improve my free MythTV remote, and I needed to "eat my own dog food", I decided to build a HTPC box for the TV room to run the MythTV frontend. I'd been interested for a while in a small, low power PC based around the Nvidia Ion chipset. A little research indicated the board to get was the Zotac IONITX-A-U as it:
  • Came in a compact, mini-ITX form.
  • Has the 64-bit capable dual core Atom 330N processor
  • Has multiple output ports including VGA, HDMI for video and SPDIF coax and TOSLink optical for audio, amongst others.
  • Gigabit Ethernet
  • External power supply to keep the heat out of the case.

The most important feature was quiet, with the related property of energy efficiency. There are many cheap PCs out there, but few can play 1080i MPEG2 videos while draining 31 Watts.



I put in 2GB of RAM which allowed me to configure the BIOS to set aside half a gig for video memory. I removed the included wireless card, as I have Gigabit ethernet in my TV cabinet, and there's no reason to waste whatever minimal energy would be used by the card. Threw in a 60 GB laptop drive I had from a few MacBooks ago, and put it in a small case. The hardest part of installing MythBuntu 9.1 64-bit, was scrounging up an external optical drive. So, all in all a very easy thing to put together.

It works fairly well. I've put my children's DVD collection on a network share and use MythVideo to watch that and recorded TV shows. Since this was my first real standalone MythTV frontend, I had to rejigger my video setup such that both the backend and frontend used both the same relative paths to videos and movie posters (both Linux boxes have paths of the form /mnt/MyNAS/MyVideos and /mnt/MyNAS/MyPosters). Once this was all setup, it's extremely convenient having a kid's movie a few touches away. I had read complaints about the fan needing to be run at a lower speed, but I really can't hear it from the couch.

    Energy usage measured via Kill-A-Watt
  • Idle Running MythTV Frontend: 25W
  • Playing DVD Image: 26W
  • Playing 720p MPEG2 (recording of 24 on Fox): 28W
  • Playing 1080i MPEG2 (Big Bang Theory on CBS): 31W
I have got to figure out how to get the box to put itself to sleep when I'm not using it.

My old LCD TV is impossible to get the VGA just right (no surprise that) so I have a two inch black bar on the right of the display, but I'll be moving to use the DVI port as soon as Monoprice gets me an HDMI switch.

It's interesting as a Mac guy seeing this little DIY assembly. On the one hand, it's pretty inexpensive and I wouldn't want to waste a Mac on single purpose computing. On the other hand, it's pretty darn cheap. Here's a photo comparing a older generation Mac Mini with my system.


The Mini is definitely a superior computer in terms of build quality. The M350 case is nice enough, but it is still ill fitting sheet metal, and the ports still wiggle and flex when you try to push a connector in. In comparison, the Mini is just rock solid, and smaller while still having a faster processor and an optical drive. And it's a darn sight more attractive. On the other hand, the Zotac has a ton of extra ports, including a variety of internal SATA and USB connectors. Different needs.

Cost:
  • Motherboard: $185
  • RAM: $45
  • Case (with Shipping): $50
  • Hard Drive: Free
  • --------------
  • Total: $280

Monday, February 01, 2010

A Cell Phone Game for Children

I was playing hide and seek with my 2 and 3 year olds, and came up with this variation.

Requirements
2 Cell phones, one of which with a speaker phone mode.
Instructions
1) Call the phone with the speaker phone mode, answer and put it in speaker mode.
2)Have someone hide the phone in another room.
3)Let the child try and find it by yelling into his phone.

Tuesday, December 22, 2009

Get the PSD Files From Your Graphic Artists

If you hired a coder to write an iPhone app, you would expect the source code along with a delivered binary. Similarly, if you hire a graphic artist, you want their source files along with a finished bitmap file. In my experience, most graphic artists use Photoshop, which means they do their editing with PSD (Photo Shop Document) files, and will export out a TIFF, PNG or JPEG as needed. You never want to edit and re-compress a PNG or JPEG and you rarely want to edit a TIFF. Which means, if you want to re-use a graphic for another purpose, you need those PSD files, or whatever file formats are native to their editing software.

An Example:

Let's say I had contracted with a third party to design my beautiful company logo.

Great.

Now two years later I need a version without the fake glassy front. If I have the original, this takes the time it takes for me to launch PhotoShop Elements, uncheck a box next to the "glassy button" layer, and export the result to web.

If I only have the PNG file, I'm basically out of luck if I can't get ahold of the artist and will have to have someone else redraw the logo from scratch.

And not only should the PSD files be in your possession, they should be in your source control system, along with all the other critical changeable items you've spent so much time and money creating.

I've been in a situation where I have literally 100 toolbar icons in PNG form and I have no easy way to make a bigger size because the outsource artist has consistently neglected to deliver the original files. Frustrating.

Also, once you have the PSD files, have a look and see if they are well organized with ample use of layers, and layer naming. Maybe, there is no way to turn off the glass button by hitting the hide layer checkbox, maybe there is only one layer, and the artist is incompetent. Maybe that's why you had to ask.

Tuesday, December 15, 2009

MythBuntu 9.10 Quickly Dying Due to missing PCHDTV firmware

So, I have been pretty unhappy with my MythTV for the last week, as something was seriously wrong with it. It would work for a while and then performance would collapse to the point I couldn't even SSH into it. Apparently, there was a massive memory leak, and the swap became exhausted resulting in the kernel doing nothing but try to find a few extra bytes.

This was after I pushed the button to upgrade to 9.10. And if there is anything I less want to do is spend more time tweaking Linux.

Anyway, I took a few minutes this morning to look through /var/log/messages and found it was jam packed with:
...
Dec 14 06:53:40 MythTV kernel: [25073.152929] or51132: No firmware uploaded(timeout or file not found?)
Dec 14 06:53:40 MythTV kernel: [25073.653032] or51132: Waiting for firmware upload(dvb-fe-or51132-vsb.fw)...
Dec 14 06:53:40 MythTV kernel: [25073.653042] cx8800 0000:02:0c.0: firmware: requesting dvb-fe-or51132-vsb.fw
Dec 14 06:53:41 MythTV kernel: [25073.902202] or51132: No firmware uploaded(timeout or file not found?)
Dec 14 06:53:41 MythTV firmware.sh[23812]: Cannot find firmware file 'dvb-fe-or51132-vsb.fw'
Dec 14 06:53:41 MythTV kernel: [25074.401098] or51132: Waiting for firmware upload(dvb-fe-or51132-vsb.fw)...
Dec 14 06:53:41 MythTV kernel: [25074.401109] cx8800 0000:02:0c.0: firmware: requesting dvb-fe-or51132-vsb.fw
Dec 14 06:53:41 MythTV firmware.sh[23823]: Cannot find firmware file 'dvb-fe-or51132-vsb.fw'
Dec 14 06:53:41 MythTV kernel: [25074.780264] or51132: No firmware uploaded(timeout or file not found?)
Dec 14 06:53:42 MythTV kernel: [25075.281031] or51132: Waiting for firmware upload(dvb-fe-or51132-vsb.fw)...
Dec 14 06:53:42 MythTV kernel: [25075.281042] cx8800 0000:02:0c.0: firmware: requesting dvb-fe-or51132-vsb.fw
Dec 14 06:53:42 MythTV firmware.sh[23839]: Cannot find firmware file 'dvb-fe-or51132-vsb.fw'
Dec 14 06:53:42 MythTV kernel: [25075.503654] or51132: No firmware uploaded(timeout or file not found?)
Dec 14 06:53:43 MythTV kernel: [25076.001099] or51132: Waiting for firmware upload(dvb-fe-or51132-vsb.fw)...
Dec 14 06:53:43 MythTV kernel: [25076.001110] cx8800 0000:02:0c.0: firmware: requesting dvb-fe-or51132-vsb.fw
Dec 14 06:53:43 MythTV kernel: [25076.266695] or51132: No firmware uploaded(timeout or file not found?)
Dec 14 06:53:43 MythTV firmware.sh[23850]: Cannot find firmware file 'dvb-fe-or51132-vsb.fw'
...

Googling "Cannot find firmware file" dvb gave me this forum post which very helpfully gave the proper command line solution:
sudo apt-get install linux-firmware-nonfree
Now my MythTV can go 20 minutes without grinding to a halt.

Now, as to whether a missing firmware to a tuner card should bring a linux distribution to a halt is another thing entirely.

Saturday, December 05, 2009

MythBuntu upgrade and mythcommflag killing my MythTV

So, I pushed the button and upgraded the MythBuntu box in the basement, and bad things happened. Oh, the new MythTV interface is lovely. But the box became utterly non-responsive. Turns out that the server had spun up 4 instances of the commercial flagging process and each was taking one quarter of the CPU. And I don't even care if my commercials get flagged or not. Anyway, went into mythtv-setup and turned off commercial flagging, and things got a whole lot better.

How Not to Ask For A Feature

"best RDP" reviews my Signal GH iPhone app for HDHomerun

Title: "piece of junk"
Body:"This thing is worthless until they add QAM cable scanning capabilities."


First of all, the "they" is me, Glenn Howes—father of two, husband, software engineer, PhD Chemist, and occasional iPhone developer. I have made a grand total of $392.05 on this app, yet still found the time to release 2 updates to it when it made absolutely no monetary sense to do so. My work is not junk, it is of the highest engineering quality I could make it. I've spent hours tracking down bugs, ran static analysis of the code, put the executable through performance instruments for memory allocations and performance, and optimized the launch time. I did this when I had other paying projects waiting my time because I like this little app and I want it to be as perfect as I can make it.

It just lacks a feature you desire, a feature which is neither promised nor implied by the product description in iTunes. If you had e-mailed me requesting this feature, I would have seriously considered including it even though an app, who's primary function is monitoring antenna signal quality is not going to be very interesting looking at digital cable traffic. Now, I'm not inclined to add this feature, and you have only your bad social skills to blame.

Wednesday, November 18, 2009

My Unibody MacBook had Been Grinding to a Halt

I'm used to my Macs being reliable; of going months between forced restarts. And yet, two weeks ago, I found myself restarting my unibody MacBook a couple times an hour. Apps would just lock up with the spinning disk cursor, and I'd go to another app and it would soon lock up to. I associated this with something fairly disk intensive, like doing a Spotlight search, and I found that if I avoided Spotlight things would be OK most days. I tried rebuilding the Spotlight database, reinstalling 10.6.0, upgrading to 10.6.2, etc., with no help.

Finally, under the working theory something was wrong with my 500 GB Western Digital Scorpio Blue drive, I ordered and installed a new 640 GB Western Digital Scorpio Blue drive. And this worked. I don't know if it was the hardware or the completely clean install or the act of reinserting the drive, but it worked and my Mac is back to its normal reliable self. And I've got more disk space than I know what to do with. I learned my lesson a few years back about waiting for a hard drive to fail; I no longer give them a second chance at catastrophe.

This might be the last mechanical hard drive I ever buy for a laptop. SSD capacities are overtaking mechanical, and I would certainly pay $300 for a 512 GB SSD of reasonable read and write throughput. Maybe this time next year.

Monday, November 16, 2009

When the Books are Free - Amazon Vine

A few months ago, I noticed an invitation to join Amazon Vine program on my Amazon front page. I clicked on it, realized it wasn't a scam and signed up. And now I get 4 free things a month; from a limited catalog of newly released products. Mostly books are available, but I've also received software and iPod accessories. All I have to do is review three fourths of what I get and I stay in good standing.


It is awesome getting free stuff. The Phillips iPod dock/CD Player/Radio in the kitchen is sweet. But that is the exception, only the quickest get gadgets, and most of the time I have a choice between books and nothing. And getting a free book is hardly a bargain: It takes hundreds of dollars of my time to read, and I don't have the universe of books to pick from, I have whatever is in the newsletter, so I have to be picky and choose only titles which are of use—a book on business law for my wife's business—or of interest—a book on how to draw dinosaurs and aliens.


One nice thing is the motivation to read; to keep up my 75% review rate. It isn't often I read 3 books in 2 months. I just wish they offered more books about software engineering and fewer about adolescent vampires (or whatever constitutes juvenile fiction).


Amazon gets value from me. Under the theory I'll get offered items similar to things I buy or review, I bought a laptop hard drive from Amazon rather than Newegg; and I've been making sure to review anything that moves to push up my ranking. Just passed into the top 3000 woo hoo..


As to whether I'm unbiased about products I'm given to hold on to (I can't resell them), I think I'm OK. I certainly have a happy feeling about being given something nice, but on the other hand, a mediocre book is such a pain to trudge through, and a junky alarm clock just takes up space. So far, I've given out a variety of star ratings, pretty much in line with things I've purchased with my own dimes; maybe a bit lower as at least when I buy something on my own I have some expectation it will be of high quality.


Anyway, when you see the "Vine Voice" badge on a review on Amazon, you'll know it's somebody like me; just an ordinary consumer who likes to write reviews and lucked into getting free stuff.

Tuesday, November 10, 2009

When Apple Doesn't Follow It's Patterns: UIScrollView

A comment in UIScrollView.h
// override points. default is to call touch methods on the content subview. if -touchesShouldCancelInContentView: returns NO in order to start dragging after we have started tracking the content view, we don't drag and continue to feed events to the content subview. if -touchesShouldBegin:withEvent:inContentView: returns NO, we don't send events even if we don't drag

So basically, if you want to modify the behavior of how a UIScrollView drags, you need to create a subclass. Fine, that's basic polymorphism, but it isn't the way most UI behaviors are changed in Cocoa on the iPhone. Typically, behaviors are changed by the use of delegate objects, and there already is a UIScrollViewDelegate interface defined. It's not clear to me why touchesShouldBegin:withEvent:inContentView and touchesShouldCancelInContentView were not just added to the delegate.


Why is this important? Well first of all, one of the joys of Cocoa programming on the iPhone is that the object model tends to be more consistent then desktop Cocoa. Everything fits together, and you know where to look for the hook which allows you to customize your app's behavior.


Secondly, I think Apple was right to choose the delegate model over object subclassing. It's less fragile, in that you are less likely to rely on the original object's behavior being constant. And some Cocoa objects are basically impossible to subclass; for instance UIButton cannot be subclassed because it isn't a "real" object. And from a coding point of view, the delegate solves both the problem of changing behavior and intercommunicating between objects.


So, when you see a comment like the above, it sticks out like a sore thumb in what is normally a disciplined and consistent API.

Monday, November 02, 2009

New Version of Signal GH

Apple has sent me a notice that version 1.1.3 of Signal GH—my iPhone app to get the signal quality of OTA TV broadcasts with an HDHomerun—is available for download. There's nothing flashy about this release, just a variety of bug fixes, including some pretty vexing ones.

Monday, October 05, 2009

iPhone as Baby's First Computer

My son, Wil, wanted to paint on my unibody Macbook this evening. He turned four in September and this was the first time he'd wanted to drive Dad's computer. In the past, "we've" painted by him telling me to "draw an alien fighting a dinosaur." So, I setup Pixelmator in full screen mode, started him up with a blue brush, and let him go to town while I watched The Amazing Race next to him on the couch. And he basically figured it out, with occasional hints from me. He figured out how to switch tools without input from me, and was playing with radial gradients with an arbitrary selection mask in no time. I did notice he was drawing everything with his tiny thumb, which allowed him to put his weight behind mouse clicks on the MacBook's zero button trackpad; I think he would master a traditional trackpad, but the MacBook's trackpad allowed him to better transfer skills he learned from his first computer: my iPod Touch.


He's been using the iPhone interface since he was still 2, and I can still remember my astonishment that he'd mastered the drag to unlock maneuver without any help from me. One of many things, he figured out himself. Thankfully, he has yet to pick up typing my password so he has not been buying apps, although he will make daily trips to the app store looking for new games and will ask me to read the user reviews. He watches YouTube videos and my own collection of videos, plays games, paints, and looks through photos, and has been doing so this entire time. His 2 year old sister does the same, except she has no interest yet in all but the simplest children's games.


In the few times they've ventured to touch my MacBook, they expect that something will happen when they touch the screen. Direct manipulation is so obvious and engrained in how they deal with computers. I've worried if I could even teach them to use a mouse, which seems so foreign and backwards as an input device. But after today's session, I'm not worried. Wil can figure things out; the MacBook trackpad is close enough to what he knows. And he enjoyed learning. I could see how happy he was to learn that pressing the command and z keys would undo drawings.


Friday, September 04, 2009

Garbled Fonts in Xcode 3.2 Console with Snow Leopard

When I upgraded to Xcode 3.2 along with Snow Leopard, the output to the console was filled with apparently random garbage, and lots of white space. This also happened in Safari when a page used a fixed space font. I don't know exactly what was going on, but I think that at some point I had set both of these font sets to some version of either Monoco or Courier, and when I installed Snow Leopard, the particular font I had used went away which confused the applications in question.

Anyway, I went to the Debugger preference tab in Xcode (not the Fonts & Colors tab) and changed all the various console fonts to be some variant of Menlo. Similarly, in Safari, I set the Fixed Width Font to Menlo-13, and all was right with my world.

[Update: this also affected the AppleScript Editor, and the font was Courier]

{Update 2: Further investigation using the Font Book application found two conflicting copies of Courier /System/Library/Fonts/Courier.dfont with a modification date of July 2009 and /Library/Fonts/Courier TU with a modification date in June 1996. Removing the older font and restarting my apps has fixed the problem.]

Saturday, July 25, 2009

The Truthiness of Things I Said on DotNetRocks

When I recorded a recent episode of DotNetRocks I recorded my side of the conversation so that the sound engineers would have a cleaner copy of what I said then what went through the phone lines. And I've listened to what I said several times, and every time I do, I find a mistake I made; things I should and did know but in the course of talking quickly for an hour off the cuff didn't get quite get right.

  • Said that Adobe had taken over development of Java for OS X when I should have said they took over the Java SWT.
  • Should have kept my opinion of Java GUIs to myself since I haven't used SWT
  • Confused NSSortDescriptor with NSPredicate when it came to extracting Core Data
  • I strongly implied that Cocoa was for GUI work when of course, it's great for most aspects of application development including threading and networking
  • Completely garbled the relationship properties of Core Data objects
  • Turns out that the C++ paths dialog in Visual Studio is actually resizable. It's just really easy to miss the drag target.


Also, I say "You Know", "Like", and "Uh" way too often; and I was completely unaware that I did so.

Tuesday, July 21, 2009

"I'm A Mac Programmer; and a Mac User. And We are Arrogant People"

“I’m a Mac programmer, and a Mac user, and we are arrogant people. And we love beauty.”

I've never been a guest on a podcast before, so my hour talking to the guys on DotNetRocks was one of the more interesting things I've done all year. And it is amazing what came out of my mouth, including the above quote.

This was in context of my describing the cloudy future of cross-platform development and how I was uninterested in any development strategy that didn't involve using Cocoa for the GUI on the Mac. I don't know that I've ever used the word arrogant to describe something positive before, perhaps a better word would have been demanding, but then again maybe it was the right word.

I'll put up a note when they post the show in the coming weeks.

Saturday, July 18, 2009

On Xcode 3.1 versus Visual Studio 2008

Recently, the DotNetRocks Podcast had an episode where the guest spent an hour slamming Xcode, Objective-C, and the Cocoa frameworks, and how awful iPhone development was in comparison to Visual Studio, C# and .Net. The guest went so far as to diagnose anyone enjoying the iPhone toolchain with Stockholm syndrome.

I wrote the hosts a scathing e-mail, pointing out that I had used a lot of frameworks, and a lot of IDEs—including regular use of Visual Studio for the last 7 years—and that the iPhone coding experience, with the exception of the annoyance of code signing, was second to none in fun. Apparently, the folks at dotnetrocks have a policy for dealing with over the top ranters, they invite them on the show. I'll be recording an episode Monday.

This blog post is part of the process of organizing my thoughts for that show. If I go on and say I like Xcode 3.1 better than Visual Studio 2008, the question will immediately become why. And the reasons behind that are either absolute i.e., that some aspect of Xcode allows me to do a better job than Visual Studio just by having a better thought out design, or personal in that Xcode is embedded in a Mac, and I love my Mac. This post cannot hope to be inclusive and I'll focus on things I don't like about Visual Studio that are done well on Xcode 3.1.

Project Properties

I recently needed to turn off the "/GL" flag in the release build of a C++ project on Windows (because a google of an arcane linker error code said that flag was involved.) So, I had to find that flag in the project properties. And, of course, in Visual Studio, if you don't know where a property is kept, you have to click through all the categories and subcategories until you find it. In this case, despite being about linking it was under Configuration Properties:C/C++:Optimization:Whole Program Optimization
BTW, all these web ready PNGs are just the way OS X takes screen shots. If only I knew how to make Windows XP take partial screen shots directly into PNG.

On Xcode on the other hand, all the properties are visible at once:And what's that at the top of the page? A search field, you mean I can just paste in the parameter and it will find it? Yes, yes I can.

And what's this thing in the corner "Based on", you mean if I have a project (a solution in Visual Studio speak) with a bunch of sub-projects (a project in Visual Studio speak) that I can create a set of configuration files that are shared amongst some of them and overrided as needed and not have to go to every single project and change its settings when I want to add a path?

And speaking of paths, doesn't this include path dialog dialog look a bit small? Oh, you can resize it like nearly every other window in Xcode Why? Because Xcode was written in Cocoa where resizing views and windows is easy.
Hey it looks like the Visual Studio include path dialog is resizable too. But only horizontally not vertically, I guess people only need two paths. [Update: turns out it was just really hard to resize, at least for me. The traction corner was not the proper target.]

Profiling

As anyone who's ever coded with me knows, I believe in the power of profiling. It is something I do as part of my personal development process. Both Xcode and Visual Studio have profiling tools. Xcode's tools go by the name of Instruments and they are prominently available in the Run menu.Here is the Object Allocations Instrument where I can ferret out performance problems indicated by too many object allocations or having objects hang around too long. For instance, earlier in the year, I ran into a problem where I was adding a timer to my run loop every tenth of a second, this was not technically a leak and would not have been solved via garbage collection but did show up in the allocations instrument as a worrisome growing number of CFTimerRefs. Notice that you can analyze and experiment on a running copy; you do not have to deal with after the fact reports.

And you can find the stack trace of every allocation.

As for Visual Studios profiling tools, well I know they are there, as I have used them in the past to find some performance problems and leaks in C++, but I can't even find them right now; that's how ill layed out Visual Studio is that something as critical to the development process as profiling is hard to find. Regardless, as I recall, the tools included were of the old fashioned variety where you ran the app, quit and the profiler would crank away for a minute or two and give you a report which you could browse through and dig into call sequences to find out for instance what fraction of the time was spent in a given method and its children. Useful, but really bare bones. And this article on Microsoft's site indicates the situation is similar when doing .Net development.

Static Analysis

It is a good idea to run your code through a static analyzer every now and again to pick up the little bits of idiocy we all suffer through. In .Net, the popular analyzer is FxCop and while I haven't personally used it, I have had our outsource team run analysises and the results have been quite useful especially when dealing with the code of junior engineers. You can get a free static analyzer for Mac and iPhone development too: Clang and I have used it and it's great at making sure your code is following the rules. Please run it before every release.

Layout

It probably is redundant, that I, a Mac user since high school, prefer the appearance and layout of Xcode to Visual Studio. It's also pretty much a given that where I see large mouse targets and esthetically pleasing use of space, a Visual Studio aficionado will see wasted space and a lack of important buttons. (BTW, if you are a PC user new to the Mac, use your left thumb to hold down the command key not your pinkie like you would if it were the CTRL key. Yes habits are hard to break, that does not mean the Mac's primary meta key is in a stupid place, far from it.)

My biggest peeve about Visual Studio is how easy is to undock an embedded subwindow while doing something else. Honestly how often does one rearrange their project panes? And then I have to figure out where to drag the window back to given this onscreen display:

My second peeve would be the amazingly small tool icons. Monitors are large and getting higher resolution. Icons 4x as big as these would be more appropriate for today.

Number 1 Favorite Features I'd Like to Find in Visual Studio

The open quickly dialog (command-shift-D) in Xcode used to be functional, but a bit lame compared to the one that had been in Metrowerks CodeWarrior, now it's one of the greatest things ever. Just open it up and start typing and as like as not, you will find the file you are looking for in a dynamically filled search list. And it is amazingly fast.
I say like to find, because Visual Studio is so filled with impossible to discover features, it might just have it already.
[Update: Philippe writes to say
Also, a neat trick in Visual Studio that mimics "Open Quickly" is this:

1. Set the focus to the Search field in the toolbar

2. Type ">of " followed by the filename (e.g. ">of MyF")
]

Getting Better All The Time

Long time Mac coders will recall that when Xcode first came out it was much worse (at the very least as a C++ IDE) than the product it killed: Metrowerks CodeWarrior which was a refined, lightning fast IDE beloved by most. But over the years, Xcode has gotten better by fits and starts. And since the iPhone took off, it's been getting better by leaps and bounds. Code completion, which used to be useless is now indispensable. The linker has gotten much faster and memory savy. The new llvm compiler which replaces gcc is fast, stable, and thankfully even tougher on iffy code. I've actually started using in-editor debugging to look up variable values, and like I said before the Open Quickly dialog is fantastic.

To Sum Up

I like Xcode. It is an Apple product, with all the good that entails: esthetics, selective choice of features, performance, ease of use. From a base of high quality, it continues to improve. I suspect it will soon integrate such technologies as Clang or openCL and become even better. PC programmers moving over to iPhone development should give it a chance and try to grok how and why it is the way it is.
[Update: content updated since first post]

Saturday, June 27, 2009

The lagging edge

I was taking my daily glance through MacSurfer when I was struck by a press release from WaveMetrics announcing a new version of Igor, the data graphing program. That brought back memories, Igor was my absolute favorite graphing program back when I was in Chemistry grad school in the early 1990s and it could always be depended upon to make the slickest output of the myriad Mac or Windows programs used at what was then called the Center for X-Ray Lithography. I have not seen it since graduating in 1995, and it is good to see it is still alive.

But what really caught my eye, that it is now in 2009 that Igor has moved to Quartz rendering from QuickDraw. According to Wikipedia Quartz was first demonstrated at the 1999 WWDC and has been the recommended mode of rendering on OS X since its introduction. Such is the inertia in the software business that an application as graphically intensive as Igor, a program which would benefit hugely from the modern features one gets for little effort with Quartz, takes 10 years to make the transition.

I wonder if the proximal cause of this laggard transition is the impending doom of Snow Leopard, where QuickDraw using 32-bit apps are distinct second class citizens. A "Pro" graphing app, might well benefit from 64-bit status, and to do that every single QuickDraw call must be expunged. Apple had spent enough time on carrots in making Quartz a beautifully clean API generally superior to QuickDraw in every way, and is now bringing down the stick of enforced obsolescence to bring the last stragglers into the fold.

I will be doing this transition over the course of the summer, myself. I'm down to 800 or so deprecated symbol warnings, so I've a ways to go before the day job application sees 64-bit nirvana.

Tuesday, June 09, 2009

Star Trek Lessons for Safari

A little noted part of Monday's WWDC keynote was the final feature set for Safari 4. Safari now has searching of browsing history. This reminds me of this exchange in the first season of Star Trek: The Next Generation:

Cmdr Riker: "Data, I need help in locating some library-computer information. All I have is a vague memory of reading somewhere about someone taking a shower in his or her clothing."
Lt. Cmdr Data: "Ah. The body Geordi discovered."
Cmdr Riker: "And I believe it may have happened before."
Lt. Cmdr Data: "To 'someone,' 'somewhere.'"
Cmdr Riker: "Should be easy for someone written up in biomechanical texts."
Lt. Cmdr Data: "About that... did the doctor believe I was boasting?"
Cmdr Riker: "Probably. This may take some time?"
Lt. Cmdr Data: "At least several hours. But what I said was a statement of fact."


It would take Data several hours to search all of Star Fleets records for instances of people showering in their clothes. Such records are quite voluminous. Searching for "shower clothes" gets 23,200,000 hits on Google now, it must be many times more in Data's day.


However, the proper data set to search is every bit of text that Riker had ever read, a much smaller set. As every viewer knows, Star Fleet personnel rarely read paper books, those tend to be kept in glass display cases; they read Kindles. And it wouldn't take much programming to keep track of every page that was ever displayed on a Kindle, or displayed in the browser on your computer.


If I remember seeing a bit of information I now need, like the name of the product manager for Keynote (yes I happen to want to know this), it would be quicker looking in web pages I've seen than it would be googling against all of man's knowledge. I doubt I read as many as 100 pages a day. My browser history says I visited 120 URLs on Monday, and that was a heavy day. Humankind as a whole must be writing 10s of millions of English text pages a day, and has been doing so for quite some time.


But to be truly useful, this data set has to be maintained over one's entire life, and include computers, smart phones, Kindles, and every other gadget that tells us something. So, history search is in Safari, but that's only a start.

Tuesday, May 26, 2009

The Wonders of the iPhone Star Rating

So, I have my free MythTV remote in the iPhone App Store and it only has a 2 star average rating.



Not exactly a Gaussian distribution.

I think that there are a class of iPhone users who download every free app they can get their hands on, whatever it's description of use, and then later tidy up, delete the app and give it a 1 star rating. For free apps, you should only go by the ratings of people who bothered to write a review.

Of course, reviewers can be pretty picky. Here are some nearly representative 1 star reviews for RRgh:

“Trop compliqué, pas ergonomique, trop cher.. bref! tout faux. A déconseiller fortement." (Google translates this as "Too complicated, not ergonomic, too expensive .. short! all wrong. A highly recommended.” 1 Star


“I love this because of it's ease of use. All who done know time consuming getting myth to work the way you it is so this application come is a fresh breath of air. I use myth on my 64bit Suse 11.0 box an it took me less than 3 minutes to set up my box to work with the app. I want to note that mymote has not worked for me yet which is disappointing because I think the interface looks better. Just remember that your default port is 6546 and your ip of your myth box. After that just enable it in the setup/utilities -- setup -- general option.” 1 Star


“A virtually flawless app I use it all the time, no more looking for the remote, it's always in my pocket! My only suggestion is to add the ability to schedule recordings if possible
Thank you
Dave” 1 Star


I will freely admit that out of 10 reviewed 1 star ratings, 7 didn't like the app, mainly because they didn't know MythTV. Fair enough, MythTV is not for the casual computer user, or someone who gets paid by the hour. My major point, if I had a point, is you should read the reviews of free apps, their star rating is not generally helpful.

Monday, April 27, 2009

On the Motivation for Updating a Free iPhone App

When I sat down to learn iPhone development, I settled on writing a remote control for MythTV as a first product. And thus Remote Remote GH for MythTV or RRgh came into existence. As MythTV users are pretty adamant about not paying for software, I decided not to charge for it, and considered it only a teaching exercise. And that worked out pretty well. I learned a lot and other people have paid me a good hourly wage for writing custom apps with the experience thus gained.


But now I have an app with 76,307 downloads and no revenue. What do I owe the users? Most of them, I'm pretty sure, just downloaded it because it was free, and promptly deleted it—and typically gave me a one star rating, ugh—when it didn't do anything useful without a MythTV frontend. But there are people out there who use it, and I'd like to give them a little goodwill. How to justify it?


1) Advertising for other products.
I can put a splash screen that announces my paying apps. Right now that would be mainly Signal GH, which a great number of MythTV users will find useful, and which I sold a grand total of $10.50 of product just this last week. But I've ideas for other products in the pipeline.


2) Further Learning.
After reading Clean Code I've been scouring my code for ways to improve its readability. The code for RRgh was written when I was just getting a handle on using Objective C 2.0's properties extension, and is a good target for cleaning. And cleaning code is sort of fun in a mechanical washing the dishes sort of way.


3) Just to be Nice.
Hey, I like having users, and it makes me happy thinking they are happy. There were some rough edges around RRgh and I think my users would be happy for me to sand them down.


So I sat down and started cleaning. As I said, my major problem was with inexperienced usage of properties. I went through and made sure I was creating, accessing and disposing all the properties in the app properly.

And then I went after the interface. I had had this idea of having a defiantly plain interface using just standard OS widgets. Turns out people didn't appreciate what I was going for. So, following popular demand, I opened up Photoshop Elements and started drawing a black on black interface for my remote controls. The idea being something that wouldn't be too distracting in a darkened home theatre room, and which would look reasonably tasteful. I used a variety of button shapes to keep things consistently themed, but not oppressively so. Plus I took the opportunity to improve the spacing and sizing of the various controls, in particular, I felt it important to make the Play/Pause button easier to hit by making it a double size.


I also went through the reviews people had submitted. Someone had wanted a record button on the LiveTV remote, etc. Perfectly reasonable and easily done.

Before and After:





Then I took the Object Allocation Instrument to the running code in the hopes of finding code that was leaking. Turns out the system image picker (UIImagePickerController) is hard to dispose, so I ended up just reusing one. Result: the app doesn't crash after setting the logo for a dozen or so networks.


In total, I gave my users about 10 hours of my time sanding down rough edges, and made RRgh a noticeably nicer product. I hope they find it useful.

Sunday, April 12, 2009

On the cost of USB versus Analog Headsets

I have children. Children love to destroy audio headsets, whether it be tearing out the ear padding, chewing up the wind guard, or taking a scissors to the cord, they will get the job done. And headsets can be expensive, especially if they have a USB connection. Searching for Logitech headsets on newegg.com, in 3.5 mm and USB varieties (and tossing out the most and least expensive in both categories) we can clearly see that analog headsets cost about $16 while USB headsets cost about $36 on average. This USB premium is something that has to be paid every time a headset is replaced.


However, there are USB devices with 3.5 mm headphone and microphone jacks which allow the user to use analog headsets. They cost about $20 (no surprise). As children are unlikely to destroy those, you just have to buy the one, and afterwards just buy a cheaper analog set to replace the one Junior split in two.

Monday, April 06, 2009

The Kindle iPhone App and the Return of Reading

Here is a picture of good intentions.

It's my little bookshelf of mainly technical books, right next to the big desk in the basement. And I regret to say, I haven't gone through even a few chapters of most of these books. Some of them are just odd choices, what was I thinking buying Linux Device Drivers? But, most are in domains either interesting, or profitable to know and yet they sit unread. The fact of the matter is that books are inconvenient and they require concentration. I'm a busy guy, and what free time I have ends up in some combination of web surfing or watching TV, usually both at once.


But like everyone, I find myself in the odd 10-20 minutes here or there. Lying in bed after the babies finally nodded off, waiting for the dentist, in a meeting starting late, etc. where I could be reading if I had a book at hand all bookmarked and ready to go. And here is where the Kindle App for the iPhone comes into play. It's always available (pockets in my PJs), no worries about lighting, always on the right page. If I activate my iPhone looking for something to do, the icon is right there on the main page. Basically, a low impedance situation to encourage me to read, and I do. I read the inspiring Clean Code cover to cover in the first week, and am halfway through Working Effectively with Legacy Code.


Not that reading a book on the iPhone is perfect. Code listings tend to be littered with confusing hyphens, and are generally hard to read. I'm sure a real Kindle is a better pure reading experience. But the thing is, I am not going to be carrying another device bigger than an iPhone on my person, ever. I'm certainly not keeping it in my pajamas. The iPhone is a good enough reader, and it's there. I could see buying a Kindle for my bedside, and relying on the automatic syncing with my iPhone, but that is way down on my spending list. What is important is that I am reading and getting the personal and professional growth which comes from reading.


Give a person a book and you change their lives.

Monday, March 09, 2009

AppleTV + iPhone Better than Mac for AirTunes

As I described in my last post, I've setup an Airport Express and a ceiling speaker to deliver music to my bathroom. This is cool technology, but after a week of it, it had the feeling of technology which was not going to become part of my daily routine. The major problem being that I had to remember to start the music playing from my MacBook before heading to the shower, and remember to shut it off afterwards. Several times, my wife made a special trip downstairs just to close the lid of my MacBook.


Then I realized this is just the sort of thing the Apple Remote app for iPhone is supposed to make easy, as I can control the music from wherever I might be in the house. And I further realized that I didn't have to leave my MacBook running all the time. The AppleTV in the living room is always on, contains my complete music collection, can be controlled by the Apple Remote app, and it can be told to send music to any AirTunes speakers on the network, including the Airport Express hooked to my bathroom speakers.


This has the major benefit of giving my wife equal control over the speakers as her iPhone can control the music as well as mine, and in a simple form her technological indifference won't mind.


So yeah, this seems right.

Thursday, February 26, 2009

iTunes to Shower Speakers

[Update: I've posted a video about installing a bathroom speaker using an Airport Express as part of an Amazon review of a
SpeakerCraft CRS6 One in ceiling speaker
. If you like it, I'd appreciate helpful votes.]

As I’ve mentioned before, the big new thing at the house the last year was a much improved moderately large shower in the basement. It’s become a locus of activity, as the babies have taken to bathing there making ad hoc bath basins out of plastic toy bins.


One thing missing would be a source of music. It occurred to me that if I could get an Airport Express mounted near the ceiling over the shower, I could use its AirTunes capability to stream music while I bathed. This would have the advantage of also allowing my wife to stream music or radio programming from her computer as well. Refurbished Airport Expresses go for $79 at the Apple online store with free shipping. Plus, I’d have another wireless N source.


[Update: Did you know that if you have an iPod Touch or iPhone, and an Apple TV, and an Airport Express, you can configure the Apple Remote for iPhone to tell the Apple TV to send its music to the Airport Express. And yes, I have all those things, and yes, Apple makes more money off me than the State of New Hampshire.]


According to the AVS Forum’s speaker section, a good in-ceiling speaker for the high humidity environment of a shower's ceiling is the Jamo 6.52DVCA2. I have done no comparing, so I cannot personally attest to how it sounds versus other in-ceiling products. It sounds fine to me, and it turns out is easy to install due to its well thought out mounting hardware. This speaker integrates both a left and right channel, so I only needed the one, and made do without much separation. This was found online for $78 shipped. [Update: Be sure to point both tweeters at where your head will be. I made the mistake of pointing one at the tiled wall, resulting in a muffled, echoey sound. Also, you might want to put some silicon sealer between the dry wall and the plastic bevel of the speaker.]


Finally, I needed a small amplifier to bridge the unamplified output of the Express with the 8Ω inputs of the speaker. Again, I am not an audio person, but I found a small 2×15 W stereo amplifier on Amazon, a Pyle Pro PCA1 Mini 2×15W Stereo Power Amplifier for $36 shipped. I didn’t suppose the small enclosed space of the shower would need any more power than that. And I was right. The system is plenty loud with the volume knob set at one quarter maximum. The amp's inputs are male RCA jacks, requiring a female RCA to mini jack adaptor. I wrote a short Amazon review on this amp, and I'd appreciate any helpful votes.


Remember, the Airport Express is not a "line out" analog device. The loudness of the output can be controlled via the volume slider in iTunes or the Apple iPhone Remote app depending on the setup. While this results in somewhat less than optimal sound, it is extremely convenient.


My original thought had been to install an electrical socket in the space above the shower and plug both the amplifier and the Airport Express there. But the only advantages to that plan would be to marginally improve my home’s WiFi coverage, and to limit any noise caused by runs of analog signals in stereo wire. Neither reason was compelling enough to justify the added expense and hassle of dealing with household current and possible building code problems. As it happened, I had a wall socket in my laundry room which was 20 feet of stereo cable from my shower's ceiling, and there is where I placed the amp and WiFi hub.



So the total required hardware:

That does tend to add up quickly, doesn’t it? Well, maybe you needed a new 802.11n wireless hub anyway.


In retrospect, I should have gotten 4 conductor in wall stereo cable instead of 2 conductor. The added complexity of dragging two cables had no benefit.


I went to Lowe's and purchased a drywall saw, safety goggles, and a dust mask; all of which made the task of cutting out the speaker mounting hole painless. It is amazing how easily a hand drywall saw cuts through drywall. The hardest part was finding a place to cut the hole where there was plenty of space in the void above the ceiling. I'd have preferred a more symmetrical arrangement with the ceiling light, but the geometry of the joists was such that my options were limited. I used gluestick to temporarily stick the provided paper template so I could very precisely mark out the hole in pencil then started cutting with the saw; very easy. The JAMO speaker easily screws into place with a hidden mount.



And now I have my shower music. Time will tell if it was worth the expense.


[Update: Energy usage. I attached everything to my Kill-A-Watt, and while playing the Airport Express and the amplifier together draw 7 W, while not playing they draw 5 W, and with the amplifier turned off the Airport Express by itself draws 3 W. So, at 5W idle, it costs much less than a dollar a month to power the system. Also, while playing my unibody MacBook draws around 17 W with its screen asleep, so a system which played music 24/7 would cost on the order of $3/month of electricity.]

Wednesday, February 25, 2009

Mythtv + HDHomerun + SheevaPlug : Connecting the Dots

Marvell just announced a 5 W Linux box with a USB 2.0 port and Gigabit ethernet, the SheevaPlug. This is a full Linux server with a 1.2 GHz processor in a box the size of a large wall wart power supply for a price of $79 US. Presumably any geeky person reading this has a dozen things they could do with such a product, and here is one: MythTV backend.


One of my problems with MythTV has been the old Pentium 4 Dell desktop I use as a backend. The monster draws upwards of 100 W. 24/7. Just to record 5 hours of TV a week and serve out videos.


Well look at what we can build now:
  • SheevaPlug 5W ($79)
  • HDHomerun 5W ($159) Dual HD TV Tuner
  • 1.5TB USB Hard Drive 10 W ($110)
  • 20 W for $348


The hard drive cost and the dual tuner are constants when building a MythTV system. I'm not counting the cost of an ethernet switch, as I assume most of us would have an extra port regardless. The major point is using a SheevaPlug for a MythTV backend would be much cheaper even then using a NetBook $250, and would very rapidly be cheaper than even re-using an old desktop $10/month electricity versus $0.50/month for just the SheevaPlug.


And it should be quiet.


On the down side, it would be useless as a frontend, and probably not up to the task of re-encoding videos.

Tuesday, February 17, 2009

When An App Rejection Improves An iPhone App

[Update: Lullabies is now in the app store. Check it out.]

I recently submitted Lullabies an iPhone App to Apple. They reviewed it for a few days and rejected it. The basic design had been that a user would choose a soothing animation/song and that animation would play to completion, and only at that point the user could choose to replay the song, or go back to pick another. Apple didn't like that. The reviewer wanted a mechanism to go directly back to the root view without waiting. Otherwise I was in violation of interface guidelines.



I did not argue. I gave them what they wanted. Touching the screen brings up a small button which will return to the animation picker.


I had been thinking that if the parent handed a child the iPhone, the child would navigate around like my own children do and not settle into being relaxed. However, it's true that they will probably hit the main button to kill the app if they are inclined, and I don't want the app to be thought of as children only. I find the app relaxing too; my brother has a great voice, and it's calming watching bubbles bounce around. And adults don't need or like boundaries in their iPhone apps. So Apple was right. It improved the app.


The second improvement came from the added time for testing the rejection gave me. Now that it was easier to go back to the root view, I actually tried it and found severe resource management problems. First, I found my animation views were not releasing. Then I was leaking animation objects every time a bubble disappeared. Then I found that animations in the root view were taking a huge amount of time while hidden, to the point where touches became non-responsive. A whole long series of problems when I just wanted to get the app out the door. But, you never get a second chance at a first impression. iPhone apps which are branded as junk rarely get their reputations back. If I put my name on a piece of software, it means I think it is a quality piece of software.


I spent most of my debugging time in the Object Allocations and CPU Sampler Instruments figuring out why my little app was misbehaving. Developers, remember that the Leaks Instrument will not find a Leak if an object is attached to the run loop, as an animation is likely to be, instead look for classes of allocations that keep having net growth over time.


That one little button Apple requested blossomed into a series of improvements, cleanups, and learning experiences. And in the end, I have a much more responsive app, and code which I'll be able to reuse in future projects.


So, thank you anonymous Apple reviewer. You did me a huge favor.

Thursday, February 05, 2009

Writing a Lullaby App for the iPhone

[Update: Lullabies is now in the app store. Check it out.]


I have 2 young children, and the familiarity and dexterity they show in using their parent's iPhones continues to amaze me. They can unlock the phone, find the YouTube app, and press on a video to play. And they are only 3 and 2 years old.


I have a brother, James Howes, who is an amazing singer, trying to make a name for himself singing opera in the Midwest. I would love to do something to advance his career.


One night, I came up with the idea of an app to help make babies sleepy, a lullaby app. Restful animations would play while Jim sang something sleep inducing. Originally, a friend of mine was going to do the animations, but he was too busy and I ended up doing the animations using CALayers and Core Animation, which was a first for me.


So here are some ideas about using CALayers on the iPhone. The first thing I did was open up Photoshop Elements and create a 320x480 document. I like Elements because it has simple vectored tools, its Save For Web... function creates excellent PNG files, and most importantly it is a layered editing program. Thus I can mock up my animation before I ever write a line of code to see what parts I need. So for a toy clock, I can combine, a background, a pendulum, a spinning moon dial, a spinning sun, and some foreground artwork. These are all exported from Elements as PNG files. PNG is the proper choice as it has decent compression while still having a transparency, and full color.










To form a toy clock of the kind one might see strapped to a crib.




If I add a layer of shadow—easily created with Element's color to transparent gradient tool—I am able to animate its opacity over the course of the animation ending with a night time scene. I like this gloaming effect better than simply making the whole scene uniformly dim.





Now that I had my parts together, I loaded each into a CALayer as so:

UIImage* moonsImage = [UIImage imageNamed:kMoonsName];
self.moonsLayer = [CALayer layer];
self.moonsLayer.contents = (id)moonsImage.CGImage;
self.moonsLayer.name = kMoonsName;
self.moonsLayer.opaque = NO;
[self addSublayer:moonsLayer];
self.moonsLayer.zPosition = 2;
self.moonsLayer.contentsGravity = kCAGravityResizeAspectFill;
[self.moonsLayer addAnimation:[self spinningAnimation] forKey:@"transform"];

Note, I made use of the zPosition to make sure my parts are drawn in the right order, and that I have a method that creates a CABasicAnimation spinningAnimation. I made a variety of CABasicAnimations to rotate the moon layer, spin the sun and swing the pendulum. You might have noticed that the center of the sun is the center of the moon dial is the center of the clock as a whole is the rotation point of the pendulum. This is not a coincidence; it makes figuring things out a whole lot easier. The pendulum graphic I used extends from the rotation point to the tip of the pendulum, although most of it is transparent.


I also made animations of snow falling, and bubbles bouncing. The hard part was simulating a bubble's iridescence (rainbow effect) in the Core Animation on the iPhone, believe me it would have been easier if Apple provided support for a proper masking layer as they do on the desktop.

It was darn hard getting my brother's audio tracks. Singing lullabies is not part of his normal repertoire—Rossini is more his speed—and he had no easily available recording facilities. The first tracks he sent me sounded like they were sung in an oak closet (better known as my cousin's kitchen). But after a very long time, he delivered the tracks I wanted, and I think they sound pretty good:
Down in the Valley. Note that any imperfections are caused by my amateurish editing skills; Jim is a singing machine.


Thankfully, Apple brought out the AVAudioPlayer class in the 2.2 SDK. It makes playing music much easier than the previous method of messing with AudioQueues. So actually playing the music was falling off a log easy.


So that's that. It was great learning about Core Animation, and I've ended up making good use of the skills in a per hour job this last month. And I hope to make more children apps in the future. I just hope this one makes a little money along the way.

Sunday, December 14, 2008

How I Drive Around With My iPhone

If you insert your iPhone's headset into your iPhone, and then plug an iPhone to USB connector into the bottom connector, the phone has a very useful set of behaviors. Regular audio such as music or podcasts will go out the bottom connector—which in my case ends up coming out my car's speakers—while phone conversations will go through the headsets. Also, the click button on the microphone works to pause (single click), answer (single click), hang up (single click) and skip to next track (double click).


Therefore, when I get into the car for my commute home, I plug my headset into the phone, put the right—microphone—ear bud into my ear, and then plug the phone into my car's stereo system. The order this is done is important. Then, as I'm driving around, if someone calls me, I can answer the phone, hang up, and skip tracks all without looking. Be warned, might be illegal in your locality.

Thursday, November 27, 2008

A Tech Support Mystery

Last week, my co-worker Gerald came to my cube saying his PowerMac G5 was consistently locking up after starting up and bringing up Entourage. He had come to me as I am the Mac programmer on staff, and therefore considered to know all things Macintosh.

I went down to his cube to find the G5 unresponsive to mouse clicks; locked up just has he had said. Very odd. After a few seconds of futzing around I realized that the machine did respond to right clicks. And a few seconds later, Gerald mentioned in passing that every time he restarted, the optical drive ejected. I immediately knew what the problem was. Can you solve this mystery? Answer below.
















The left mouse button of his Logitech mouse was stuck in the clicked state. Thus the machine was non-responsive to mouse clicks, and as everyone should know, holding down the mouse button while restarting will eject the optical drive of a Mac. I went and got a Mighty Mouse, plugged it in and the machine worked perfectly.

Friday, November 14, 2008

Patience Needed for Switching .mpg Application

My MythTV records over the air broadcasts as .mpg (MPEG) files of several gigabytes each. My preferred mode of viewing them these days is to open up a SMB share on the MythTV box, copy the file over to my MacBook while I'm working and then view it later. Amongst the many annoying things about this process—inefficient SMB transfers, avoiding having Time Machine back up the show, OS X not letting me watch a partially transferred file—a small one is that Quicktime owns the .mpg extension, when it'd be nice if VLC did. But every time I would open a Get Info window on a .mpg file the whole Finder would lockup, apparently generating the preview. And then I'd relaunch the Finder after a minute or so. So I never was able to click the Change All... button.

Turns out that the Finder will eventually, after several minutes, give up with creating a preview, and you can change the Open With application to VLC and then click the Change All... button. So be patient.

Friday, November 07, 2008

Sleep Advice for Geeky Fathers

As a father of young children, I have some advice for my fellow software engineers in similar boats who want time for their side projects. At some point, if you are lucky, your children will be sleeping from their bedtime of say 9:00 PM to maybe 7:00 AM depending on their natural needs. My advice is to work within this framework when it comes to your own sleep schedule.


Every day, come home from work, play with your children till their bedtime, fall asleep as they do and wake up naturally. For me, falling asleep at 9:00 PM will mean waking up in a quiet, empty house at 4:30 AM with 2½ hours of time to work on my software projects and catch up on my TV watching before the children awake. I will spend the rest of the day fully rested, and at my peak performance. Compare with the alternative strategy of staying up after the babies' bedtime which if I "get on a roll" might keep me up till 12:30 AM, with no margin for error. What if the babies wake up at 6:00 AM as they sometimes do? I'll spend the rest of the day under a sleep debt: low performing and grumpy.


Also, my recommended strategy allows you to pay off your sleep debt. If you do this and wake up later than expected the first few days, you had an accumulated sleep debt you needed to pay off before reaching peak efficiency.


I'm basing this advice on this Google Tech Talk which I highly recommend watching:

Thursday, November 06, 2008

When Is A Leak Not A Leak

I was sent a bug report on some software I had written a while back wherein it would become less and less responsive over time till it just sort of died. Sounds like a leak.


But when I hooked it up to the Leaks Instrument, I saw no leaks. No red peaks at all. Must not be a leak then.


But one more look. The net objects allocated were going up and up and up. This should not happen, the application should have reached an equilibrium point of net objects allocated, and oscillated around it.


So, I let it run for a while in the Objects Allocated instrument, and then examined the blocks which were being allocated and not deallocated. Turns out I had an object, an audio player, which had a scheduled NSTimer associated with it. When I released the player, it was still being referred to by the NSTimer, so it did not get deallocated. And in this case, I was creating one of these every second or so (probably not a good idea), which meant that not only was the memory leaking, but all those timers were adding overhead to the event loop. No wonder it crawled to a halt. So remember to invalidate unwanted timers.

Wednesday, October 29, 2008

Debugging a Shower

The big extravagance at the house this year is replacing the cheapest looking vinyl shower you ever saw with a very nice tile and glass block version. A friend of my wife's built it over the course of a month; it's beautiful. The babies have been learning the joys of showers over baths, and I've been spending much of my time pondering development problems from the built in granite seat.


Unfortunately, it's started leaking and in tracking down the leak, I've realized how broadly applicable the skills we pick up debugging software can be applied to the physical world.


Initial Bug Report.
After a lengthy bout of baby cleaning, my wife noticed a wet spot growing from the hallway wall shared by the new shower. She reported the bug to me as a high priority.
Observation of Bug's Behavior
The bug only manifested itself after a shower. And a shower of the babies.
Initial Conclusions
If the copper pipes inside the shower were leaking, then using the shower would be irrelevant; it would leak regardless of use. The only exception to this would be a leak in the pipe from the valve to the shower head. So no need to rip out the walls to get to the water pipes.
Experimentation
Working on the assumption that if the shower was leaking, it was doing so near the wet spot, and most likely at the most complicated part of the shower: the granite seat. So, I took my morning shower with the spray pointed away from the seat. Result: No wet spot. Conclusion, the seat was not properly sealed. There was a seam through which water could get through and into the outside world. This meshed well with the initial bug report, as the babies would tend to stand on the seat and have the spray directed at them there for long periods.
Rejected Alternative Hypothesis
Someone suggested that perhaps the flow was overwhelming the drain and a path to the outside was being reached from the bottom. This seems unlikely as the flow into the drain should be the same or less when the spray was pointed towards the seat. And 15 minutes of water directed directly at the drain disproved it.

Final Conclusions
Have to reseal all the joints, and re-grout the tile beneath the seat till we find the bad seam.

Saturday, October 25, 2008

Visual Studio 2005 C++ and the ? : operator

One thing you want in C++ compilers is consistency with other C++ compilers. Especially if you are doing cross-platform development work. I want the VS C++ compiler to interpret what I tell it to do exactly the same way that gcc interprets it. That way, I don't have to special case my compilations, and I don't create a bunch of platform specific bugs in my platform neutral code. And usually, the two compilers do agree.


However, I discovered today (Friday) that if you compile something like:
double x = (false) ? 0 : 1.4;
that x will not equal 1.4 as most people (and the gcc compiler) would think, but rather it will equal 1.0. Why? Because it sees 0, interprets it as an integer and decides that if both halves of the : have to have the same type, then that type will be integer. The fact that this is in the middle of an assignment to double means nothing.

In order for x to equal the expected 1.4, you have to write:
double x = (false) ? 0.0 : 1.4;


I'm not even saying that Visual Studio is wrong. It's different from gcc which leads to platform specific bugs, and it's unexpected so the unaware coder will type in the unwanted form and not know something could possibly go wrong.

[Update: Russell Finn goes into more language lawyer parsing of this, and believes VS C++ is wrong. (I don't know Mr. Finn, I just like to read my Site Meter page to see how people get to my blog.)]


[Update 2: And don't let me get started about how VS C++ allows you to put the closing angle brackets of a nested template declaration without a space, as in:
vector<pair<string, int>> myVectorOfPairs;

]

Thursday, October 23, 2008

News of the Not News: People Like Free iPhone Apps

This is one of those blog posts where the author has two data points and has to write an entire entry about those points. Here is the data: My iPhone app to help HDHomerun users align their antennas, Signal GH, went 5 days without a sale. This despite getting a favorable mention on a well known podcast on Friday. So I temporarily started giving it away to boost exposure and reviews. A day later, I had 205 downloads from the U.S..

So $2.99 equals 0 unit sales per day == $0.00 profit
And $0.00 equals 205 unit sales per day == $0.00 profit

At least I'm breaking even.

I believe a large number of these downloads are pointless, as you have to have an HDHomerun to do anything at all with Signal GH. There are people who troll the back pages of the utilities section of the App Store, downloading everything free. I just hope these people don't write reviews.

Thursday, October 16, 2008

Thankful to be a Cocoa Programmer

The company I work for is interested in Microsoft's .NET framework; I am not. But, I was scrounging for free content on iTunes the other day and came across the .NET Rocks podcast, and out of idle curiosity downloaded a few episodes. They are well done, and put together by friendly people with an unflagging enthusiasm for Microsoft technologies. And they make me very happy to spend much—unfortunately not all—of my time working on Macs and iPhones.


Apparently, the target audience is comprised of developers putting together custom business applications; the kind of vertical apps corporate America (and apparently Dubai) consume by the megalines of code. Not the general purpose, high degree of finish, large user base applications I've spent much of my career writing, but database frontends and the like. It's the Bizarro world out there, where right justifying labels is considered a major advance in GUI development.


Any iPhone developers would be well served listening to the recent cast on Windows Mobile. As someone who was scrounging for work when the Mac had 3% market share, I can sympathize with the pathos of a product manager for Windows Mobile trying to put a brave face on disaster, but come on. This exchange pretty much sums up the level of wishfulness and straw grasping:
Host: So let me ask the question a different way: the next version, whatever it's called; should Apple be scared?
Rob Tiffany: Very scared.
Hosts: (laughs) YES!
Rob Tiffany: Very scared.
Hosts: I knew it.
Rob Tiffany: Yeah, yeah, we're working on some secret sauce out there.
Host: Not too secret anymore!


I will congratulate the hosts for not being blind to WinCE's current flaws: they gave Rob a hard time about how the phone app on their phone was glacially slow; I'm just amazed they think it will get better. That old saying about a second marriage being the triumph of hope over experience..


And the episode on complying with the corporate governance rules of the Sarbanes Oxley law... If I had to do that sort of thing, I'd seriously consider going to work at Home Depot. How does one show up at work every day doing that sort of thing?


And that's the thing. I'm nearly always happy either going into work—assuming I won't be spending the whole day fixing OLE bugs on the PC—or pulling out my MacBook and add a refinement to an iPhone app. Life is sweet. I get to work in an application framework which was designed right from the start; light weight and powerfully elegant. I'm not one of a hundred cogs living in a condo in Dubai; I'm a sole practitioner, or an unblended part of a small team. I write software people don't have to be paid to use. I don't have to wait for the secret sauce which never comes. I am a Cocoa programmer, and for that I am thankful.

Saturday, October 11, 2008

The Loss of Homogeneity: iPhones on the Network

Developing for the iPhone and iPod Touch is nice: limited hardware differences leads to reliability. If it works on my iPhone running the 2.1 OS, it should run well on your iPhone. They are pretty much the same. Homogeneity is good when it comes to testing for program errors.


So your iPhone is the same as mine, but your network is not.

I submitted a new version of Remote Remote GH for OS X Touch to Apple a week ago. It had been gradually gestating and stabilizing has I had time to improve it. The last several weeks, it had been quite stable, and had never been much of a crasher to begin with. Thursday night, Apple notified me that the new version was available for distribution on the App Store; Friday morning RRgh crashed on me on launch. Wha?

Backing up. I had been playing with the XBox Media Center (XBMC) for the AppleTV, and last night I had tried turning on its UPnP (Universal Plug and Play) server and client. The new RRgh's big feature is support for auto-detecting MythTV frontends via UPnP, so having another UPnP device on my network meant my code had to check to see it wasn't a MythTV. Unfortunately, this revealed a latent crashing bug where I was expecting a string, got a NULL pointer instead, and boom, boom crash. (No actual audio percussion, just a silent quit.)

An early updater experiencing (what I assume is) the same problem figured out my e-mail address and let me know that I wasn't the only one.

So, I had to quickly remove RRgh from distribution pending a 1.1.1 release, as I have no wish to get a deluge of negative reviews from whatever small fraction of the populace would be affected by this. Which means, there is no RRgh currently available for download, as I don't have the option to revert to the 1.0 binary.

If you are one of the people who downloaded 1.1, I hope it isn't crashing on you, but I've submitted an updated binary which should be out within the week.

Thursday, October 02, 2008

News of the Not News: QuickDraw Printing is Dead

As I occasionally let on, my day job is the care and feeding of an ancient, semi-well known, Carbon application (and worse its Win32 doppleganger, and worse still its Win32 doppleganger's OLE interface). One "perk" is the occasional confrontation with the living dead. The dead in question is how we print. We print using a very old and elaborate system of QuickDraw calls spiked with embedded Postscript. This creates very nice output. On Postscript printers. From PowerPC Macs.
For Intel Macs, not so good. Why? Because there is no embedded Postscript in Quickdraw printing support for Intel Macs. It didn't make the cut of creaky technologies Apple bothered porting over during the Intel transition. So, yes, text and polygons look OK, if imprecisely positioned, and that's most of our output; but anything splined based is bad as there are no splines in QuickDraw only very big polygons.
So, users of ancient Carbon applications: check out the printing on your shiny new Intel box.