3

I have a Forge Viewer embedded into an Angular 9 application. Everything seems to be working as expected apart from a standard Full Screen button. When clicked it throws an uncaught JavaScript error that can be seen in the browser's Dev console:

Uncaught (in promise) TypeError: fullscreen error
    at u (compat.js:87)
    at h.doScreenModeChange (ScreenModeDelegate.js:231)
    at h.u.setMode (ScreenModeDelegate.js:83)
    at T.setScreenMode (ScreenModeDelegate.js:337)
    at T.nextScreenMode (ScreenModeDelegate.js:354)
    at s.n.onClick (GuiViewer3D.js:737)
    at HTMLDivElement.<anonymous> (Button.js:33)

I went through the code referenced in the call stack and concluded that most likely the error happens during a call to a browser Fullscreen API and interrupts the correct sequence of switching to a full screen mode. The styling to the viewer container is applied successfully but the browser Full Screen is not entered. Also, the exit handler is not attached so exiting from Full Screen does not work as well.

I haven’t seen such a problem in any of the Autodesk Forge examples so I presume that the error is triggered by something different in my application. The error clearly happens in the Viewer code as can be seen from the console log.

Alex T
  • 39
  • 1
  • 8

3 Answers3

5

Normally This error came when a developer tries to do full screen after loading without any user action. The user must click anything on the web page before the full-screen script run.

Rehan Rajpoot
  • 158
  • 2
  • 6
2

I have found the problem after additional investigation. The error was thrown by the requestFullscreen() in the compat.js because the property document.fullscreenEnabled was set to false and the code did not check it before calling requestFullscreen.

The document.fullscreenEnabled was false because of an unexpected value received in the Feature-Policy header from the server. Apparently, the Chrome browser in response to the wrong header value sets the document.fullscreenEnabled to false but the Firefox sets it to true.

Alex T
  • 39
  • 1
  • 8
0

Try catching the promise

document.getElementById('root').requestFullscreen().then(()=>{
    console.log("fullscreen")
  },()=>{console.warn("no fullscreen")});
yeahdixon
  • 6,647
  • 1
  • 41
  • 43