Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8427283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:44:39+00:00 2026-06-10T04:44:39+00:00

The function to render my canvas is a prototyped method of a class, like

  • 0

The function to render my canvas is a prototyped method of a class, like this:

Engine.prototype.renderCameras = function() {
        console.log('render ok');
}

When I try to run this code directly, it works fine:

engine.renderCameras()
>>> render ok

When I try to run it using requestAnimationFrame, in either Chrome or Firefox, I get this:

window.requestAnimFrame(engine.renderCameras())
>>> render ok
>>> Error: Component returned failure code: 0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS) [nsIDOMWindow.mozRequestAnimationFrame]

It runs, but it always throws an error. That’s not cool.

When I try to run it like this:

window.requestAnimFrame(engine.renderCameras)
>>> 0

It just does nothing.

I was able to solve this problem by using a closure, but I’d still like to know why I can’t pass a function like that to requestAnimationFrame.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:44:41+00:00Added an answer on June 10, 2026 at 4:44 am
    window.requestAnimFrame(engine.renderCameras())
    

    is not passing a function to requestAnimFrame, it is passing the return value of engine.renderCameras to requestAnimFrame. The return value is probably not a function and that’s why you get this error.

    window.requestAnimFrame(engine.renderCameras)
    

    instead correctly passes a function reference, but then this [docs] inside renderCameras won’t refer to engine. If you rely on that (which I assume based on the setup), you either have to pass a function calling engine.renderCameras properly:

    window.requestAnimFrame(function(){
        engine.renderCameras();
    });
    

    or use .bind [docs] to set (and bind) this explicitly:

    window.requestAnimFrame(engine.renderCameras.bind(engine));
    

    Either way, you have to repeatedly call window.requestAnimFrame to get the next animation frame, which means you typically use a recursive function. For example:

    window.requestAnimFrame(function render(){
        engine.renderCameras();
        window.requestAnimFrame(render);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run a function (to render flash messages) after a backbone.navigate call.
I've subclassed Canvas so that I can override its Render function. I need to
render: function render(context, partials) { return this.r(context, partials); }, Given this code from Twitter's
I have this function whose essential operations are outlined as follows: function render($index) {
I'm trying to use the jQuery get function to render the results of an
I want to render an object from my controller to a jQuery callback function.
app.get('/', function (req, res) { res.render('home.jade', { results: req.session.value }); }); What i would
I have a function that renders RGB video frames to a window. This works
I am traing to load some images on client browser with this code: function
I have this code: function render_message(id) { var xmlHttp; xmlHttp=new XMLHttpRequest(); xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.