Skip to content

Commit

Permalink
fix(2d): fix the mesh of 2d batcher error when call gc (#1977)
Browse files Browse the repository at this point in the history
  • Loading branch information
singlecoder authored Jan 18, 2024
1 parent aa14cab commit 6ffee78
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/core/src/RenderPipeline/Basic2DBatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ export abstract class Basic2DBatcher {
const { _meshes: meshes, _vertexBuffers: vertexBuffers, _indiceBuffers: indiceBuffers } = this;

for (let i = 0, n = meshes.length; i < n; ++i) {
meshes[i].destroy();
const mesh = meshes[i];
mesh._addReferCount(-1);
mesh.destroy();
}
this._meshes = null;

Expand Down Expand Up @@ -149,7 +151,7 @@ export abstract class Basic2DBatcher {
private _createMesh(engine: Engine, index: number): BufferMesh {
const { MAX_VERTEX_COUNT } = Basic2DBatcher;
const mesh = new BufferMesh(engine, `BufferMesh${index}`);
mesh.isGCIgnored = true;
mesh._addReferCount(1);
const vertexElements: VertexElement[] = [];
const vertexStride = this.createVertexElements(vertexElements);

Expand Down

0 comments on commit 6ffee78

Please sign in to comment.