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

Improved type array to get the name of the code #5780

Merged
merged 5 commits into from Nov 23, 2019

Conversation

knoxHuang
Copy link
Contributor

@knoxHuang knoxHuang commented Nov 22, 2019

Re: cocos-creator/2d-tasks#

Changes:

  • 修复跑上 ios9 上崩溃的 bug
    原因:由于之前为了处理 ie 上 TypeArray 获取到 name 为空的问题,在代码中设置了 TypeArray 的 name,但是 ios9 系统 name 是只读的属性如果设置的话就会报错,从而导致引擎代码跑在 ios9 系统上会崩溃

let type = value.constructor.name;
if (!type) {
Copy link
Contributor

@holycanvas holycanvas Nov 22, 2019

Choose a reason for hiding this comment

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

iOS下不能赋值name,能直接用defineProperty设置的吧

Copy link
Contributor Author

@knoxHuang knoxHuang Nov 23, 2019

Choose a reason for hiding this comment

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

通过测试 defineProperty 也无法设置

else if (constructor === Uint32Array) { return 'Uint32Array'; }
else if (constructor === Int32Array) { return 'Int32Array'; }
else if (constructor === Uint8Array) { return 'Uint8Array'; }
return '';
Copy link
Member

@jareguo jareguo Nov 23, 2019

Choose a reason for hiding this comment

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

都不是的话,抛出个异常吧

@sunnylanwanjun
Copy link
Contributor

@sunnylanwanjun sunnylanwanjun commented Nov 23, 2019

!Int32Array.name && (Int32Array.name = 'Int32Array');

!Uint8Array.name && (Uint8Array.name = 'Uint8Array');
!Uint16Array.name && (Uint8Array.name = 'Uint16Array');
Copy link
Contributor

@sunnylanwanjun sunnylanwanjun Nov 23, 2019

Choose a reason for hiding this comment

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

game over

Copy link
Contributor Author

@knoxHuang knoxHuang Nov 23, 2019

Choose a reason for hiding this comment

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

修改了

@knoxHuang knoxHuang requested a review from sunnylanwanjun Nov 23, 2019
@holycanvas holycanvas merged commit a8edba6 into cocos:v2.2.1-release Nov 23, 2019
1 check passed
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

4 participants