Canvas getImageData not working on Mobile Safari-Collection of common programming errors

I am trying to extract the pixels from a canvas on mobile safari (iOS 5.0) but I am getting a strange TypeError:

> var ctx = canvas.getContext("2d");
> ctx.getImageData(0,0,canvas.width,canvas.height);

> ImageDataConstructor
    constructor: Object
    data: TypeError: 'undefined' is not an object
    height: 50
    width: 50
    __proto__: Object

Somehow this extremely trivial piece of code is not working on mobile safari (testing with Weinre) but it does run on desktop safari and chrome…. Can anyone help me? Why is the data object reporting a TypeError??

Thanks,

Rob

PS. I tried with an empty canvas, and one with actual content in it