3.5.1 重复动态添加远程龙骨资源报错 2.4.0 正常

async LoadRemoteJsonAsync(remoteUrl: string) {
    return new Promise<any>(r => {
        assetManager.loadRemote(remoteUrl, (error: Error, asset: any) => {
            if (error) {
                console.error(error);
                r(null);
                return;
            }
            if (asset instanceof JsonAsset) {
                asset = (asset as JsonAsset).json;
            }
            r(asset);
        });
    })
}

/**
 * 通过 远程url 设置精灵
 * @param url 
 * @param options 
 * @param extraData 
 * @returns 
 */
async loadDragonBoneAsync(data: {
    index: number,
    arr: any[],
    y?: number,
    skeJsonUrl: string,
    textureJsonUrl: string,
    texturePngUrl: string,
    animation?: string,
}): Promise<Node> {
    return new Promise<Node>(async r => {
        console.log('loadDragonBoneAsync -> ', data.skeJsonUrl, data.textureJsonUrl, data.texturePngUrl);
        let arr: any[] = await Promise.all([this.LoadRemoteJsonAsync(data.skeJsonUrl), this.LoadRemoteJsonAsync(data.textureJsonUrl), this.LoadRemoteJsonAsync(data.texturePngUrl)])
        let tex_png_asset = arr[2]
        let tex_png = new Texture2D()
        tex_png.image = tex_png_asset

        try {
            let node = new Node();
            // node.setPositionXY((600 / data.arr.length) * data.index, data.y || 0);
            node.SetNodeLayer(Layers.Enum.UI_2D);
            let armatureDisplay = node.addComponent(dragonBones.ArmatureDisplay);
            armatureDisplay.enabled = false;
            let _dragonAsset = new dragonBones.DragonBonesAsset();
            _dragonAsset.dragonBonesJson = JSON.stringify(arr[0]);
            let _dragonAtlasAsset = new dragonBones.DragonBonesAtlasAsset();
            _dragonAtlasAsset.atlasJson = JSON.stringify(arr[1]);
            _dragonAtlasAsset.texture = tex_png;
            
            armatureDisplay.dragonAtlasAsset = _dragonAtlasAsset;
            armatureDisplay.dragonAsset = _dragonAsset;
            armatureDisplay.armatureName = 'armatureName';
            armatureDisplay.enabled = true;
            data.animation && armatureDisplay.playAnimation(data.animation, 0);
            
            // this.node.addChild(node);

            console.log('=====DB>loadDragonBoneAsync', data.animation, data.texturePngUrl)
            r(node);
        } catch (e) {
            console.error('=====DB>loadDragonBoneAsync', JSON.stringify(data), e);
            r(null);
        }
    });
}

上面是动态创建加载远程龙骨资源的方法,然后执行

   main() {
    let arr = ["https://xcxgame.qingzhanshi.com/mlzb/common/db/mlzb_rw00/ske.json?v=3",
        "https://xcxgame.qingzhanshi.com/mlzb/common/db/mlzb_rw00/image/front_hair/tex.json?v=1",
        "https://xcxgame.qingzhanshi.com/mlzb/common/db/mlzb_rw00/image/front_hair/tex.png?v=1",
        "front_hair"
    ]
    let addDBFunc = async() => {
        let itemNode = await this.loadDragonBoneAsync({
            index: 0,
            arr: arr,
            y: 300,
            skeJsonUrl: arr[0],
            textureJsonUrl: arr[1],
            texturePngUrl: arr[2],
            animation: arr[3],
        })
        itemNode && this.node.addChild(itemNode);
    }
    addDBFunc() //添加一个不会有问题
    addDBFunc() //添加第二个就会有问题

}

就会报错

Error: Assertion failed: <no-message>
at assertIsTrue (asserts.ts:46:15)
at StaticVBAccessor.allocateChunk (static-vb-accessor.ts:172:13)
at RenderData.resize (render-data.ts:197:37)
at Object.createData (simple.ts:167:16)
at ArmatureDisplay._flushAssembler (ArmatureDisplay.ts:1274:48)
at ArmatureDisplay._buildArmature (ArmatureDisplay.ts:923:14)
at ArmatureDisplay._refresh (ArmatureDisplay.ts:962:14)
at ArmatureDisplay.set (ArmatureDisplay.ts:228:14)
at EntryPoint.ts:103:17
at Generator.next (<anonymous>)

请问下是什么原因呢 @jare @washaobang_wkmail @引擎开发团队

顶一下顶一下

顶一下顶一下

顶一下顶一下

Web环境?

就是在web环境上测试的

@zzf_Cocos 帮忙看看

在线等回复

再顶一次!

好的,我们会看下


已经有 issue 在跟了

有临时解决方案了吗,项目着急修改

解决方案:

1赞

感谢,3.6.3正好遇到