Egret Engine 5.3.10 version is released, mainly to fix the lag problem based on iOS14 system

Today Egret Engine 5.3.10 version is officially released. The main content is to fix the three problems of mesh freeze on iOS14 system, htmlsound sound cannot be returned after mounting to the background, and keel model display abnormality.

Up to now, although the Egret Engine5.3 series is still a beta version, the product functions have stabilized. Developers who have problems with lagging are recommended to upgrade!

If your online project uses the stable version of the Egret Engine 5.2 series and you don’t want to upgrade the engine version to solve the lag problem, we provide you with a second set of solutions, you need to manually modify the following in the Egret Engine 5.2.X version Code for 2 positions:

Position 1: WebGLVertexArrayObject.ts
cacheArrays method

 .......

            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 {
              ......

Position 2: WebGLRenderContext.ts
drawTexture method

  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;
            .........

The above two solutions can solve the lag problem caused by the iOS14 system, and everyone can choose according to the project situation. If you encounter problems while using Egret Engine, you can contact the official customer service WeChat account: egretengine, we will help you solve it as soon as possible!

Guess you like

Origin blog.51cto.com/11960887/2538084