Egret Engine 5.3.10版本发布,主要修复基于 iOS14 系统的卡顿问题

今天Egret Engine5.3.10版正式发布,主要内容是修复iOS14 系统上 mesh 卡顿、htmlsound 声音挂载到后台后无法返回以及龙骨模型显示异常三个问题。

截至目前,虽然Egret Engine5.3系列依然属测试版,但产品功能已趋于稳定,建议有卡顿问题的开发者升级处理!

如若您的上线项目使用的是Egret Engine 5.2系列的稳定版,且不想升级引擎版本解决卡顿问题,我们为您提供了第二套解决方案,需要您在Egret Engine 5.2.X版本中手动修改以下2个位置的代码:

位置1:WebGLVertexArrayObject.ts

cacheArrays方法

 .......
 if (meshVertices) {
 let vertData = [];
 // 计算索引位置与赋值
 const vertices = this.vertices;
 const verticesUint32View = this._verticesUint32View;
 let index = this.vertexIndex * this.vertSize;
 // 缓存顶点数组
 let i = 0, iD = 0, l = 0;
 let u = 0, v = 0, x = 0, y = 0;
 for (i = 0, l = meshUVs.length; i < l; i += 2) {
 iD = index + i * 5 / 2;
 x = meshVertices[i];
 y = meshVertices[i + 1];
 u = meshUVs[i];
 v = meshUVs[i + 1];
 if (rotated) {
 vertData.push([
 a * x + c * y + tx,
 b * x + d * y + ty,
 (sourceX + (1.0 - v) * sourceHeight) / textureSourceWidth,
 (sourceY + u * sourceWidth) / textureSourceHeight,
 ]);
 } else {
 vertData.push([
 a * x + c * y + tx,
 b * x + d * y + ty,
 (sourceX + u * sourceWidth) / textureSourceWidth,
 (sourceY + v * sourceHeight) / textureSourceHeight,
 ]);
 }
 verticesUint32View[iD + 4] = alpha;
 }
 for (let i = 0; i < meshIndices.length; i += 3) {
 let data0 = vertData[meshIndices[i]];
 vertices[index++] = data0[0];
 vertices[index++] = data0[1];
 vertices[index++] = data0[2];
 vertices[index++] = data0[3];
 verticesUint32View[index++] = alpha;
 let data1 = vertData[meshIndices[i + 1]];
 vertices[index++] = data1[0];
 vertices[index++] = data1[1];
 vertices[index++] = data1[2];
 vertices[index++] = data1[3];
 verticesUint32View[index++] = alpha;
 let data2 = vertData[meshIndices[i + 2]];
 vertices[index++] = data2[0];
 vertices[index++] = data2[1];
 vertices[index++] = data2[2];
 vertices[index++] = data2[3];
 verticesUint32View[index++] = alpha;
 // 填充数据
 vertices[index++] = data2[0];
 vertices[index++] = data2[1];
 vertices[index++] = data2[2];
 vertices[index++] = data2[3];
 verticesUint32View[index++] = alpha;
 }
 let meshNum = meshIndices.length / 3;
 this.vertexIndex += 4 * meshNum;
 this.indexIndex += 6 * meshNum;
 } else {
 ......

位置2:WebGLRenderContext.ts

drawTexture方法

let buffer = this.currentBuffer;
 if (this.contextLost || !texture || !buffer) {
 return;
 }
 let meshNum = meshIndices && (meshIndices.length / 3) || 0;
 if (meshIndices) {
 if (this.vao.reachMaxSize(meshNum * 4, meshNum * 6)) {
 this.$drawWebGL();
 }
 } else {
 if (this.vao.reachMaxSize()) {
 this.$drawWebGL();
 }
 }
 if (smoothing != undefined && texture["smoothing"] != smoothing) {
 this.drawCmdManager.pushChangeSmoothing(texture, smoothing);
 }
 // if (meshUVs) {
 //     this.vao.changeToMeshIndices();
 // }
 let count = meshIndices ? meshNum * 2 : 2;
 .........

以上2种方案均可解决基于iOS14系统带来的卡顿问题,大家可根据项目情况自行选择。使用Egret Engine期间如若遇到问题,可联系官方客服微信号:egretengine,我们会第一时间帮您解决!

阅读 68

推荐阅读