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

window.crypto.getRandomValues(array) breaks when loaded together with Meteor (for example) #1197

Closed
driesvancraen opened this issue Sep 17, 2014 · 3 comments

Comments

@driesvancraen
Copy link

I noticed that when Phaser is loaded together with Meteor in my case,
window.crypto.getRandomValues(array) stops working.
If I try without Phaser being loaded, I get

var array = new Uint32Array(10); window.crypto.getRandomValues(array);

I get:

[948945600, 3374845945, 3984172385, 110198777, 2902514722, 2978147553, 3769228441, 3954409512, 3650036860, 3809070537]

When I try the same when Phaser is loaded I get:

javascript
TypeError: Type error
line: 1
message: "Type error"
stack: "getRandomValues@[native code]↵eval code↵eval@[native code]↵_evaluateOn↵_evaluateAndWrap↵evaluate"
__proto__: Error

This happens only in Safari...

Any thoughts on this?

@photonstorm
Copy link
Collaborator

Does Safari have native support for Uint32Array? If not my guess is that the polyfill for it isn't compatible with window.crypto. Or maybe the Safari Uint32Array is being overwritten regardless by one of the Pixi / P2 polyfills bundled in Phaser, and it's causing the same issue anyway.

This could actually explain the reason why lots of the pixel manipulation commands in BitmapData don't work in Safari, because they use Uint32Array too, and if something has borked Safaris use of it then it explains a lot. I'll investigate further.

photonstorm added a commit that referenced this issue Oct 5, 2014
…rray on Safari, causing errors like BitmapData.getPixel32 to fail and other related issues (fixes #1043 and #1197)
@photonstorm
Copy link
Collaborator

Ok I figured out the reason for this and it was indeed the Uint32Array polyfill for IE9 causing it. Please re-test (against dev branch) and this should be fine now.

@driesvancraen
Copy link
Author

solved!

FluffyDeluxe pushed a commit to FluffyDeluxe/phaser that referenced this issue Oct 27, 2014
…rray on Safari, causing errors like BitmapData.getPixel32 to fail and other related issues (fixes phaserjs#1043 and phaserjs#1197)
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

No branches or pull requests

2 participants