BUG: texture.readPixels() returns 0 on android(Cocos Creator 2.0.10)

BUG: texture.readPixels() returns 0 on android(Cocos Creator 2.0.10)
0

Hi, starting from version 2.0.10 there is a problem with this script on android. This script cuts out ar rounded rectangle form from texture(confusing circle cut naming is because before that it did cut circle). In 2.0.10 version it still works in simulator and on web, but when I tested on 2.1.2 it also didn’t work in simulator. Could you please tell me should I use different approach? It works in 2.0.9, but I don’t want to be stuck with this version of Cocos Creator.

        if (cc.circleCutRTex == undefined) {
            cc.circleCutRTex = new cc.RenderTexture();
        }
        let rtex = cc.circleCutRTex;
        //if ((rtex.width != tex.width) || (rtex.height != tex.height))
        rtex.initWithSize(tex.width, tex.height, 0);
        rtex.drawTextureAt(tex, 0, 0);
        //!!!read pixels returns zeros on Android and in later versions(2.1.2) in simulator
        let data = rtex.readPixels();
        let rSquared = Math.pow(tex.width / 2, 2);
        for (let y = 0; y < tex.height; y++) {
            for (let x = 0; x < tex.width; x++) {
                let offset = (y * tex.width + x) * 4;
                if (Math.pow(x - tex.width / 2, 2) + Math.pow(y - tex.height / 2, 2) > rSquared) {
                    data[offset + 3] = 0;
                }
            }
        }
        tex.initWithData(data, cc.Texture2D.PIXEL_FORMAT_RGBA8888, tex.width, tex.height, new cc.Size(tex.width, tex.height));
        return tex;

This may be caused by dynamic atlas manager, you can do as this code:
cc.dynamicAtlasManager.enabled = false

Another way is to fix the engine code as a temporary solution.

Thank you very much for pointing out the problem! You guys are great!