-->

Getting webGL error in autodesk viewer

2020-04-14 03:29发布

问题:

I am getting error like: Uncaught TypeError: Cannot read property '__webglFramebuffer' of null

when i am going to another page linked with the page which has autodesk viewer attached . I dont know why it is coming . I am using angularjs for my web site and there is no code in controller of that page about viewer.

回答1:

You are getting this error because you do not destroy the viewer instance on the page you left, so when receiving event such as page resize the viewer will try to re-render and since the WebGL context has been destroyed it will fire this error.

Simply place some cleanup handler called when you navigate away from the viewer page, depending on which version of angular you are using you should find how to that easily, then place following code to cleanup the viewer:

// assumes this.viewer contains your viewer, your code might be different ...
// make sure viewer has been created
if (this.viewer) {

  // I added this to handle some specific cases
  if(this.viewer.impl.selector) {

    this.viewer.tearDown()
    this.viewer.finish()
    this.viewer = null
  }
}