Skip to content

Conversation

a49594a
Copy link
Contributor

@a49594a a49594a commented Apr 11, 2017

Resolves

fix exception "Invalid offset/length when creating typed array" in ms edge browser

Proposed Changes

just convert the float to integer use Math.floor

new Uint8Array(Math.floor(bounds.width * bounds.height * 4))

Reason for Changes

new Uint8Array(10.1)
if the parameter of the Uint8Array constructor is not integer, chrome browser ignor the 0.1, but the edge browser throw an exception "Invalid offset/length when creating typed array".

just run the playground of scratch-vm or the scratch-gui in the edge browser, and use f12 develop tools to change the size of the stage, then you will got the exception

fix exception "Invalid offset/length when creating typed array" in ms edge browser
Copy link
Contributor

@cwillisf cwillisf left a comment

Choose a reason for hiding this comment

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

Hi, @a49594a! Thanks for contributing!
I have two requests for this change:

  1. Please fill out the pull request template. You can do this by editing the PR description and replacing the italic text under the headers like "Resolves" and "Proposed Changes" and the rest. This helps make sure everyone understands the purpose of each pull request, including Scratch team members and other contributors.
  2. Could you explain why Edge needs this change? Do Edge's typed array constructors handle the length argument differently? You can put this information in the "Reason for Changes" section of your PR description if you'd like to do both of these things at once :)

@a49594a
Copy link
Contributor Author

a49594a commented Apr 18, 2017

new Uint8Array(10.1)
if the parameter of the Uint8Array constructor is not integer, chrome browser ignor the 0.1, but the edge browser throw an exception "Invalid offset/length when creating typed array".

@cwillisf cwillisf changed the title Update RenderWebGL.js Fix typed array exception in Edge Apr 19, 2017
@cwillisf
Copy link
Contributor

Thanks again, @a49594a! I rearranged your description a little bit in case that helps explain what the different parts of the template are for. I also gave the PR a descriptive name instead of just "Update RenderWebGL.js"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants