多摄像机在iphone6系列机型下出现渲染停止画面卡住

  • Creator 版本:2.0.8

  • 目标平台: 微信小游戏

  • 详细报错信息,包含调用堆栈:

iPhone 6 直接画面卡死,但是可以听到声音,所以触摸也可以点到界面的按钮,感觉就是渲染停止了

  • 重现方式:iphone6 多摄像机

场景上有两个摄像机,一个主的一个副的,还有一个脚本,两个精灵节点。

用这几个东西做了一个把界面动态模糊的效果,就是副摄像机的渲染赋值到两个精灵节点,然后让精灵节点随机移动。

其它机型上正常。iphone6系列机子经过测试渲染停止。脚本代码二楼发。

节点布局

主摄像机配置

副摄像机配置(现在停用了,因为有问题。)

脚本挂载在Canvas下

import UtilTool from “…/…/…/…/…/Script/framework/utils/UtilTool”;
import WxUserData from “…/…/…/…/…/Script/data/WxUserData”;
import SystemData from “…/…/…/…/…/Script/data/SystemData”;

// Learn TypeScript:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

const { ccclass, property } = cc._decorator;

@ccclass
export default class ChildCameraNode extends cc.Component {

@property(cc.Node)
result_node: cc.Node = null;

@property(cc.Node)
zui_context: cc.Node = null;

@property(cc.Node)
zui_context_z: cc.Node = null;

@property(cc.Camera)
camera: cc.Camera = null;

private _RadomAnim: boolean = false;

// LIFE-CYCLE CALLBACKS:

onLoad() {
    if (SystemData.Model.indexOf("iPhone") != -1 && SystemData.Model.indexOf("6") != -1) {
        console.warn("iiphone6 ????????");
        return;
    }
    this.camera.enabled = true;
    let renderTexture = new cc.RenderTexture();
    let gl = cc.game._renderContext;
    renderTexture.initWithSize(cc.view.getViewportRect().width, cc.view.getViewportRect().height, gl.STENCIL_INDEX8);
    // ßrenderTexture.setPremultiplyAlpha(true);


    let spritef = new cc.SpriteFrame();
    spritef.setTexture(renderTexture);
    this.zui_context.getComponent(cc.Sprite).spriteFrame = spritef;
    this.zui_context_z.getComponent(cc.Sprite).spriteFrame = spritef;
    this.camera.targetTexture = renderTexture;
    this.camera.enabled = false;
    //this.zui_context.x = 10;
}

start() {

}

startAnim() {
    this.camera.enabled = true;

    this._RadomAnim = true;
    this.RadomAnim();
}

stopAnim() {
    this.camera.enabled = false;
    this._RadomAnim = false;
    this.zui_context.stopAllActions();
    this.zui_context_z.stopAllActions();
    let action = cc.spawn(
        cc.moveTo(0.5, 0, 0).easing(cc.easeQuadraticActionOut()),
        cc.fadeTo(0.5, 0).easing(cc.easeInOut(0.5))
    );
    let action_z = cc.spawn(
        cc.moveTo(0.5, 0, 0).easing(cc.easeQuadraticActionOut()),
        cc.fadeTo(0.5, 0).easing(cc.easeInOut(0.5))
    );
    this.zui_context.runAction(action);
    this.zui_context_z.runAction(action_z);
}

RadomAnim() {
    //console.log("startanim",this._RadomAnim);
    if (this._RadomAnim) {
        let x = UtilTool.random(6, 9);
        let y = UtilTool.random(6, 9);
        // let o = UtilTool.random(30, 50);
        // let o_z = UtilTool.random(10, 50);
        let o = UtilTool.random(66, 150);
        let o_z = UtilTool.random(66, 150);
        let action = cc.sequence(
            cc.spawn(
                cc.moveTo(1, x, y).easing(cc.easeQuadraticActionOut()),
                cc.fadeTo(1, o).easing(cc.easeInOut(1))
            ),
            cc.delayTime(0.3),
            cc.spawn(
                cc.moveTo(0.5, 0, 0).easing(cc.easeQuadraticActionIn()),
                cc.fadeTo(0.5, 0).easing(cc.easeInOut(0.5))
            ),
            cc.delayTime(4),
            cc.callFunc(this.RadomAnim, this)
        );

        let action_z = cc.sequence(
            cc.spawn(
                cc.moveTo(1, -x, -y).easing(cc.easeQuadraticActionOut()),
                cc.fadeTo(1, o_z).easing(cc.easeInOut(1))
            ),
            cc.delayTime(0.3),
            cc.spawn(
                cc.moveTo(0.5, 0, 0).easing(cc.easeQuadraticActionIn()),
                cc.fadeTo(0.5, 0).easing(cc.easeInOut(0.5))
            ),
            // cc.delayTime(4),
            // cc.callFunc(this.RadomAnim, this)
        );
        this.zui_context.runAction(action);
        this.zui_context_z.runAction(action_z);
    }
}

update(dt) {
    if (SystemData.Model.indexOf("iPhone") != -1 && SystemData.Model.indexOf("6") != -1) {
        return;
    }
    //console.log(WxUserData.zui.now / WxUserData.zui.up * 100,this._RadomAnim);
    if (this._RadomAnim) {
        //?????????????????
        if (this.result_node.active) {
            this.stopAnim();
        } else {
            let bf = WxUserData.zui.now / WxUserData.zui.up * 100;
            if (bf >= 80) {
                return;
            } else {
                this.stopAnim();
            }
        }
    } else {
        let bf = WxUserData.zui.now / WxUserData.zui.up * 100;
        if (bf >= 80) {
            if (!this.result_node.active) {
                this.startAnim();
            } else {
                return;
            }
        } else {
            return;
        }
    }

}

}

请问 你后来调好了么? 我这边 wx小游戏 多摄像机 某一个摄像机 调用camera.render()的时候 其他的摄像机就会停止自动渲染 同样也是ios遇到的问题。 安卓无问题 web ios 和Android都没问题。

又定位了一下问题 情况还不是调用camera.render()的时候 是给camera.targetTexture 绑定一个RenderTexture 之后 camera.render()到这都没问题。 但是之后再执行 RenderTexture.readPixels就会停止渲染