New Image onload sometimes is not fired on Android and iPhone


#1

Hi, I am developing an app for devices like Android and iPhone using Ionic. In one page, I need to load the local image to the canvas. I new image and in onload callback to draw the image to the canvas. But I met an issue, the onload callback sometimes is not fired. It happens on iPhone7, iPhone6, Samsung Galaxy S6 and Nexus 5.

Here is the relevant code:

    var base_image = new Image();

    base_image.onload = function() {
        drawCanvas(base_image);
    };

   base_image.src = $scope.imageSrc;  //base 64 image data

I’d really appreciate any help.