Jump to content

state change error (null is not an object (evaluating "canvasBuffer.context.scale"))


CodeCycle
 Share

Recommended Posts

Hey Guys

I'm struggling with an error on safari/ios... the first 5 times the state change works. but after the 5th time the error "null is not an object (evaluating 'canvasBuffer.context.scale')" appears.

I traced the error back to the graphics.generateTexture(); function. as already said after the fifth state change the error occurs at the third execution of the command (the command is executed 3 times per state).

Do you have any idea what it is or how to circumvent it?

Thanks

 

IMG_2194.thumb.PNG.04ece1fe6e9a927939f84bd5d10c811a.PNG

Link to comment
Share on other sites

  • 1 year later...

This error occurs when you read a property or call a method on a null object . That's because the DOM API returns null for object references that are blank. An object is expected somewhere and wasn't provided. So, you will get null is not an object error if the DOM elements have not been created before loading the script. In JavaScript , null is not an object; and won't work. You must provide a proper object in the given situation.

We can resolve this type of issues by adding an event listener that will notify us when the page is ready. Once the addEventListener is fired, the init() method can make use of the DOM elements.

  document.addEventListener('readystatechange', function() {
    if (document.readyState === "complete") {
      init();
    }

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...