skip to Main Content

If we start the Viewer, but a navigation happens in between, we have the following problem.

Forge Viewer Error

This would be not such a problem if it would not log it only once, but it seems there is some kind of loop, and we are getting a lot of those errors. Also, it impacts the browser performance as well.

The following message also gets printed, but I would not know how we can avoid that leak.
Leaking viewer instance error message

This seems to happen from the Version 7.90.0 onwards. With the Version 7.89.0 we would get the following error:

Forge Viewer Error 7.89.0

But this error gets logged only once, and we experienced no performance issues.

Will there be fix in some upcoming versions, or how could we tackle this issue?

Steps to reproduce:

  1. Start up a viewer instance
  2. Quickly navigate back
  3. Wait for errors in console

Update

We already call the folllowing functions on the ngDestroyHook:

  • viewer.tearDown()
  • viewer.current?.uninitialize()
  • this.viewer.finish()
  • Autodesk.Viewing.shutdown();

2

Answers


  1. You need to destroy the viewer instance, once the component gets unmounted, inside the ngOnDestroy hook.

      ngOnDestroy() {
        if (this.viewer && this.viewer.impl.selector) {
          this.viewer.tearDown();
          this.viewer.finish();
          this.viewer = null;
        }
      }
    
    Login or Signup to reply.
  2. It did not matter which version I used (v7.89 or v7.97 – the latest one at the moment) I got similar results in my very simple vanilla html page.

    If I remove the Viewer component from the DOM while it’s loading a model I get:

    Uncaught TypeError: Cannot read properties of null (reading 'tBodies')
        at SettingsPanel.addRow (viewer3D.js:60936:90)
        at SettingsPanel.addSliderV2 (viewer3D.js:61008:24)
        at ViewerSettingsPanel.addSliderV2 (viewer3D.js:65537:98)
        at ViewerSettingsPanel.initScrollSpeed (viewer3D.js:65747:17)
        at ViewerSettingsPanel.createNavigationPanel (viewer3D.js:65702:42)
        at new ViewerSettingsPanel (viewer3D.js:65333:8)
        at GuiViewer3D.createSettingsPanel (viewer3D.js:57670:23)
        at GuiViewer3D.initModelTools (viewer3D.js:57683:8)
        at GuiViewer3D.createUI (viewer3D.js:57254:8)
        at createUI (viewer3D.js:57154:12)
    

    If I set the Viewer size to 0 while it’s loading a model I get:

    Uncaught TypeError: Cannot read properties of null (reading '__webglFramebuffer')
        at WebGLRenderer.initFrameBufferMRT (viewer3D.js:105990:56)
        at WebGLRenderer.setRenderTarget (viewer3D.js:106090:12)
        at LMVRenderer.setRenderTarget (viewer3D.js:88815:59)
        at RenderContext._render (viewer3D.js:94489:14)
        at RenderContext.renderScenePart (viewer3D.js:94601:12)
        at Array.cmdSceneAfterRender (viewer3D.js:26104:15)
        at RenderCommandSystem.executeCommandList (viewer3D.js:25801:42)
        at Viewer3DImpl.tick (viewer3D.js:26791:10)
        at animloop (viewer3D.js:26830:17)
    

    (if I call viewer.impl.resize(0, 0) more than once the same error gets into an endless loop)

    Here is the html page I used for testing: https://github.com/adamenagy/Container/blob/master/revit-reload.html

    If these do not help narrow down the issue on your side then the best would be if you could provide a minimal (as small and simple as possible) sample for us to use to reproduce the issue on our side.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search