今天Egret Engine5.3.10版正式发布,主要内容是修复iOS14 系统上 mesh 卡顿、htmlsound 声音挂载到后台后无法返回以及龙骨模型显示异常三个问题。
截至目前,虽然Egret Engine5.3系列依然属测试版,但产品功能已趋于稳定,建议有卡顿问题的开发者升级处理!
如若您的上线项目使用的是Egret Engine 5.2系列的稳定版,且不想升级引擎版本解决卡顿问题,我们为您提供了第二套解决方案,需要您在Egret Engine 5.2.X版本中手动修改以下2个位置的代码:
位置1:WebGLVertexArrayObject.ts
cacheArrays方法
1 ....... 2 3 if (meshVertices) { 4 let vertData = []; 5 // 计算索引位置与赋值 6 const vertices = this.vertices; 7 const verticesUint32View = this._verticesUint32View; 8 let index = this.vertexIndex * this.vertSize; 9 // 缓存顶点数组 10 let i = 0, iD = 0, l = 0; 11 let u = 0, v = 0, x = 0, y = 0; 12 for (i = 0, l = meshUVs.length; i < l; i += 2) { 13 iD = index + i * 5 / 2; 14 x = meshVertices[i]; 15 y = meshVertices[i + 1]; 16 u = meshUVs[i]; 17 v = meshUVs[i + 1]; 18 19 if (rotated) { 20 vertData.push([ 21 a * x + c * y + tx, 22 b * x + d * y + ty, 23 (sourceX + (1.0 - v) * sourceHeight) / textureSourceWidth, 24 (sourceY + u * sourceWidth) / textureSourceHeight, 25 ]); 26 } else { 27 vertData.push([ 28 a * x + c * y + tx, 29 b * x + d * y + ty, 30 (sourceX + u * sourceWidth) / textureSourceWidth, 31 (sourceY + v * sourceHeight) / textureSourceHeight, 32 ]); 33 } 34 verticesUint32View[iD + 4] = alpha; 35 } 36 for (let i = 0; i < meshIndices.length; i += 3) { 37 let data0 = vertData[meshIndices[i]]; 38 vertices[index++] = data0[0]; 39 vertices[index++] = data0[1]; 40 vertices[index++] = data0[2]; 41 vertices[index++] = data0[3]; 42 verticesUint32View[index++] = alpha; 43 44 let data1 = vertData[meshIndices[i + 1]]; 45 vertices[index++] = data1[0]; 46 vertices[index++] = data1[1]; 47 vertices[index++] = data1[2]; 48 vertices[index++] = data1[3]; 49 verticesUint32View[index++] = alpha; 50 51 let data2 = vertData[meshIndices[i + 2]]; 52 vertices[index++] = data2[0]; 53 vertices[index++] = data2[1]; 54 vertices[index++] = data2[2]; 55 vertices[index++] = data2[3]; 56 verticesUint32View[index++] = alpha; 57 58 // 填充数据 59 vertices[index++] = data2[0]; 60 vertices[index++] = data2[1]; 61 vertices[index++] = data2[2]; 62 vertices[index++] = data2[3]; 63 verticesUint32View[index++] = alpha; 64 } 65 66 let meshNum = meshIndices.length / 3; 67 this.vertexIndex += 4 * meshNum; 68 this.indexIndex += 6 * meshNum; 69 70 } else { 71 ......
位置2:WebGLRenderContext.ts
drawTexture方法
1 let buffer = this.currentBuffer; 2 if (this.contextLost || !texture || !buffer) { 3 return; 4 } 5 6 let meshNum = meshIndices && (meshIndices.length / 3) || 0; 7 if (meshIndices) { 8 if (this.vao.reachMaxSize(meshNum * 4, meshNum * 6)) { 9 this.$drawWebGL(); 10 } 11 } else { 12 if (this.vao.reachMaxSize()) { 13 this.$drawWebGL(); 14 } 15 } 16 17 if (smoothing != undefined && texture["smoothing"] != smoothing) { 18 this.drawCmdManager.pushChangeSmoothing(texture, smoothing); 19 } 20 21 // if (meshUVs) { 22 // this.vao.changeToMeshIndices(); 23 // } 24 25 let count = meshIndices ? meshNum * 2 : 2; 26 .........
以上2种方案均可解决基于iOS14系统带来的卡顿问题,大家可根据项目情况自行选择。使用Egret Engine期间如若遇到问题,可联系官方客服微信号:egretengine,我们会第一时间帮您解决!