Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

emscripten_set_main_loop

Discussion in 'WebGL' started by hassank, Feb 18, 2016.

  1. hassank

    hassank

    Joined:
    Nov 18, 2015
    Posts:
    48
    I'm deploying my Unity project to WebGL and get the following warning:

    Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!

    This does not crash my deployment but, as warned, the frame rates are suffering.

    I'm new to WebGL deployments but I've learned that using 0 for the frame rate will allow me to use requestAnimationFrame and render at an appropriate rate. However, can someone tell me where to call emscripten_set_main_loop? Do I put it in a Unity file, js file, or is it running somewhere already?
     
  2. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    that warning comes from emscripten when calling emscripten_set_main_loop, which we do at engine initialization time.

    which version of unity are you on ?
    have you changed Application.targetFrameRate or vsync in QualitySettings ?
     
    hassank likes this.
  3. hassank

    hassank

    Joined:
    Nov 18, 2015
    Posts:
    48
    Hey Marco, I'm on 5.3.1 and working on an open-source project. V Sync Count is set to "Don't Sync" and Application.targetFrameRate was set to 60 via script. I removed the Application.targetFrameRate and the warning no longer appears. Thank you!

    Out of curiosity, it sounds like emscripten_set_main_loop cannot be called directly. Is that correct?
     
  4. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    not really, since the first parameter would need to be the function pointer of Unity's internal main loop. What is it that you would like to achieve ?
     
    hassank likes this.
  5. hassank

    hassank

    Joined:
    Nov 18, 2015
    Posts:
    48
    Nothing in particular. Just wanted a better understanding of how it's all working and really curious about what's going on under the hood.

    Thanks for the help!