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

This comment has been minimized.

Copy link
@holycanvas

holycanvas Nov 22, 2019

Contributor

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

This comment has been minimized.

Copy link
@knoxHuang

knoxHuang Nov 23, 2019

Author Contributor

通过测试 defineProperty 也无法设置

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

This comment has been minimized.

Copy link
@jareguo

jareguo Nov 23, 2019

Contributor

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

@sunnylanwanjun

This comment has been minimized.

Copy link
Contributor

sunnylanwanjun commented Nov 23, 2019

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

!Uint8Array.name && (Uint8Array.name = 'Uint8Array');
!Uint16Array.name && (Uint8Array.name = 'Uint16Array');

This comment has been minimized.

Copy link
@sunnylanwanjun

sunnylanwanjun Nov 23, 2019

Contributor

game over

This comment has been minimized.

Copy link
@knoxHuang

knoxHuang Nov 23, 2019

Author Contributor

修改了

@knoxHuang knoxHuang requested a review from sunnylanwanjun Nov 23, 2019
@holycanvas holycanvas merged commit a8edba6 into cocos-creator:v2.2.1-release Nov 23, 2019
1 check passed
1 check passed
ci/circleci: test Your tests passed on CircleCI!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.