3

I have an html5 webapp that recently was broken on iOS6. We take a high resolution jpeg image and render it on a canvas element. We first load a lower resolution thumbnail as a placeholder while the higher resolution jpeg downloads in the background. In iOS6 the high resolution image, once loaded gets way out of aspect on the y dimension. Here is a sample page I created as a test that just switches between a thumbnail and a high resolution image:

http://www.video-monitoring.com/beachcams/jupiter/canvas.htm

If you test this on iOS6 you will see the high res image get squished.

Here is the javascript code:

        var imgCanvas;
    var imgContext;
    var downloader = new Image();
    var w = 400;
    var h = 300;
    var hq = true;
    var lqUrl = "http://www.video-monitoring.com/beachcams/jupiter/pics/s2/sep0112k/s211403_.jpg";
    var hqUrl = "http://www.video-monitoring.com/beachcams/jupiter/pics/s2/sep0112k/s211403w.jpg";

    window.onload = function () {
        imgCanvas = document.getElementById('canvas');
        imgContext = imgCanvas.getContext('2d');
        downloader.onload = imageOnLoad;
        downloader.src = hqUrl;
    }


    function imageOnLoad() {
        imgContext.clearRect(0, 0, w, h);
        imgContext.drawImage(downloader, 0, 0, w, h)
    }

    function btnClick() {
        hq = !hq;
        if (hq) downloader.src = hqUrl;
        else downloader.src = lqUrl;
    }

Here's the html:

    <input type="button" name='changeres' id='changeres' onclick="btnClick()" value='Change Resolution' />
<canvas width="2000px" height="1000px"  id="canvas">

</canvas>

So my question is what has changed in iOS6 where this is now rendered incorrectly? Is there something I am doing that is not standard? It renders properly on all other browsers. It works in iOS5. Here's the production version of the webapp: http://www.video-monitoring.com/beachcams/jupiter/slideshow.htm

Torchify
  • 134
  • 7
  • Ok so I see on Apple's known bugs for iOS6 that they changed the jpg sub-sampling from 2mp to 5mp. So maybe its just their algorithm that's boinked. – Torchify Sep 21 '12 at 20:43
  • I have found a simular thing. Any solutions yet? – NimmoNet Sep 24 '12 at 13:59
  • Not yet.. I submitted a bug report to Apple. I see there are others with the same problem. Do a search on drawimage() ios6. Unfortunately, I'm probably going to code around this by disabling the high res images on ios 6. – Torchify Sep 26 '12 at 17:38
  • Do you know how to step down the resolution of images coming from the iphone on the file picker in safari? – NimmoNet Sep 28 '12 at 12:40
  • 1
    Looks like someone created a library to fix this bug: https://github.com/stomita/ios-imagefile-megapixel http://stackoverflow.com/a/12615436/1689781 – Torchify Oct 10 '12 at 21:38

0 Answers0