Search code examples
androidhtmlwebkithtml5-canvas

Canvas not rendering on Android 4.2.2


Steps of reproduction:

  • Use 4.2.2. Android system (but not cyanogen mod since the issue is fixed there)
  • Make a webview and serve it a canvas element through a server
  • You get a black screen / it does not render canvas at all

Correct behaviour: You serve it a canvas element and it renders what it is on it. It works on all possible android versions we were able to test except the 4.2.2. .
We confirmed the problems on at least these devices which are at the moment running this version of Android: Moto G, Samsung Galaxy SII, Samsung Galaxy SIII , Samsung Galaxy SIV, HTC One X, HTC One S mini...

I presume the bug is already known but i was not able to find it or more accurately not able to find any way of reproduction. If anyone knows if there is any workaround it would be nice


Solution

  • you can try this, it work for me on HTC device:

    in html:

    <canvas style="background-image:-webkit-canvas(mask);" />
    

    in javascript:

     var ctx = document.getCSSCanvasContext("2d", "mask", 150, 80);
     //now you free to use canvas normally