Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed taobao-minigame use bitmapfont sometimes error #17023

Merged
merged 6 commits into from
Jun 12, 2024

Conversation

zhefengzhang
Copy link
Contributor

Re: #17022

@@ -126,6 +126,8 @@ export default class Assembler2D extends Assembler {
indiceOffset = offsetInfo.indiceOffset,
vertexId = offsetInfo.vertexOffset;
for (let i = 0, l = iData.length; i < l; i++) {
//Because taobao-minigame does not allow out-of-bounds access to Uint16Array, otherwise it will report an error and cause the game to be unresponsive
if (cc.sys.platform === cc.sys.TAOBAO_MINIGAME && indiceOffset + 1 >= ibuf.length) break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last member can not be set normally.

@@ -126,6 +126,8 @@ export default class Assembler2D extends Assembler {
indiceOffset = offsetInfo.indiceOffset,
vertexId = offsetInfo.vertexOffset;
for (let i = 0, l = iData.length; i < l; i++) {
//Because taobao-minigame does not allow out-of-bounds access to Uint16Array, otherwise it will report an error and cause the game to be unresponsive
if (cc.sys.platform === cc.sys.TAOBAO_MINIGAME && indiceOffset >= ibuf.length) break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • why do it in for loop, can determine how much data to copy before for loop
  • this PR means that on tabao platform, some data will not be copied into ibuf, can it work correctly on tabao platform?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, after project testing, this PR will not cause any abnormalities in the game, and it has solved the problem of the game not responding. I will try to handle this issue in a more performant way.

@zhefengzhang
Copy link
Contributor Author

zhefengzhang commented May 27, 2024

When increasing the value of indiceOffset, it should not exceed the array length of buffer._iData.

image

image

@@ -125,7 +125,7 @@ export default class Assembler2D extends Assembler {
let ibuf = buffer._iData,
indiceOffset = offsetInfo.indiceOffset,
vertexId = offsetInfo.vertexOffset;
for (let i = 0, l = iData.length; i < l; i++) {
for (let i = 0, l = this.indicesCount; i < l; i++) {
ibuf[indiceOffset++] = vertexId + iData[i];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may exceed iData too. So i think should use the min value of them, for example

const indicesToFill = min(this.indicesCount, iData.length);

@minggo minggo changed the base branch from v2.4.14 to v2.4.15 June 12, 2024 01:52
@minggo minggo merged commit e080ae7 into cocos:v2.4.15 Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants