Skip to content

Events not received during a RAF loop #179

Closed
@paulrouget

Description

@paulrouget

Something like this:

function foo() {requestAnimationFrame(foo)}
foo()

… will prevent any window events to be received. Can't resize the window and key & mouse events are not received for example. But the UI is properly rendered and updated.

The exact code I'm using is:

<body>
  <h1>Mousemove events:</h1>
  <div id="moves"></div>
  <h1>RAF per seconds:</h1>
  <button onclick="step()">Start RAF loop</button>
  <pre id="raf"></pre>
</body>
<script>

  // Add a dot on mousemove
  document.documentElement.addEventListener("mousemove", () => {
    document.querySelector("#moves").textContent += " ."
  });


  // FPS counter
  var count = 0;

  setInterval(() => {
    document.querySelector("#raf").textContent = count;
    count = 0;
  }, 1000);

  // RAF loop
  function step() {
    count++;
    requestAnimationFrame(step);
  }

</script>

I'm not sure it's a Webrender issue. Without Webrender, some events are received, but many mousemove are missing. And the CPU spike at 120% (50% with Webrender).

If it's not WR specific, let me know, I can move this issue to servo/servo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions