Android Native Browser duplicating HTML5 canvas (fine in chrome)

后端 未结 4 1565
难免孤独
难免孤独 2020-12-31 09:47

This is a weird issue that I am only experiencing on a Native browser on Samsung Galaxy Tab 2 and Galaxy S2 in the native browser.

This has also been tested on othe

相关标签:
4条回答
  • 2020-12-31 10:03

    For double canvas issue there is a bug logged https://code.google.com/p/android/issues/detail?id=35474 you may want to check suggested solutions.

    In my case this issue appeared only if I had Force GPU rendering enabled.

    Issue usually appears if you have some parent element for canvas that has CSS overflow: hidden

    0 讨论(0)
  • 2020-12-31 10:10

    Also you may look at this collections of such tips: http://slash-system.com/en/how-to-fix-android-html5-canvas-issues/

    0 讨论(0)
  • 2020-12-31 10:17

    I ran into this same issue. I was able to fix this by running the following code after making a change to my canvas:

    // If Samsung android browser is detected
    if (window.navigator && window.navigator.userAgent.indexOf('534.30') > 0) {
    
        // Tweak the canvas opacity, causing it to redraw
        $('canvas').css('opacity', '0.99');
    
        // Set the canvas opacity back to normal after 5ms
        setTimeout(function() {
            $('canvas').css('opacity', '1');
        }, 5);
    
    }
    

    By tweaking the opacity, this forced the canvas to redraw and removed the duplicate shapes. It's a dumb fix but it works. Hopefully this helps someone.

    0 讨论(0)
  • 2020-12-31 10:17

    remove overflow property from all canvas parents,probably we don’t need this property on touch devices:

    $("canvas").parents("*").css("overflow", "visible");
    

    It is well explained at http://slash-system.com/en/how-to-fix-android-html5-canvas-issues/

    0 讨论(0)
提交回复
热议问题