You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created a script using the minimal example from the Getting Started wiki page, and included it and matter.js as content scripts in a basic Firefox Extension.
When I run the extension on a webpage, the line Engine.run(engine); raises the exception TypeError: 'requestAnimationFrame' called on an object that does not implement interface Window.
After inspecting the matter.js source I found that the problem comes from this line:
The same problem occurs with Render.run(render); and the corresponding Runner.run function in matter.js.
This seems to be because the global object in the Firefox extension's content scripts is not window but rather a different sandbox object, therefore _requestAnimationFrame is not being called on window and raises the exception.
To prove this, I replaced _requestAnimationFrame(render) with window.requestAnimationFrame(render) in both Runner.run functions and the loops successfully ran without any errors.
Using _replaceAnimationFrame.call(window, render) also works, and still maintains the cross-browser support that the original method provides.
This was tested using Firefox v61.0.2, and both Matter v0.14.2 and v0.10.0.
The text was updated successfully, but these errors were encountered:
I created a script using the minimal example from the Getting Started wiki page, and included it and matter.js as content scripts in a basic Firefox Extension.
When I run the extension on a webpage, the line
Engine.run(engine);
raises the exceptionTypeError: 'requestAnimationFrame' called on an object that does not implement interface Window
.After inspecting the matter.js source I found that the problem comes from this line:
The same problem occurs with
Render.run(render);
and the correspondingRunner.run
function in matter.js.This seems to be because the global object in the Firefox extension's content scripts is not
window
but rather a different sandbox object, therefore_requestAnimationFrame
is not being called onwindow
and raises the exception.To prove this, I replaced
_requestAnimationFrame(render)
withwindow.requestAnimationFrame(render)
in bothRunner.run
functions and the loops successfully ran without any errors.Using
_replaceAnimationFrame.call(window, render)
also works, and still maintains the cross-browser support that the original method provides.This was tested using Firefox v61.0.2, and both Matter v0.14.2 and v0.10.0.
The text was updated successfully, but these errors were encountered: