Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events not received during a RAF loop #179

Closed
paulrouget opened this issue Feb 8, 2016 · 5 comments
Closed

Events not received during a RAF loop #179

paulrouget opened this issue Feb 8, 2016 · 5 comments

Comments

@paulrouget
Copy link
Contributor

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.

@glennw
Copy link
Member

glennw commented Feb 10, 2016

@paulrouget Nice test case! However, it seems to be working correctly on Linux - I get a solid 60 fps reported and every mouse movement results in a new dot on the screen.

Perhaps @pcwalton could take a look on mac and see if it's related to the mac event loop?

@glennw
Copy link
Member

glennw commented Feb 10, 2016

@paulrouget BTW, you may find adding -Z wr-stats useful when debugging / profiling rAF or other performance related issues on WebRender.

It lets you see the frame rate, when paints occur, and some basic stats about the scene.

graphs

@paulrouget
Copy link
Contributor Author

I don't know if that helps, but this is what I get:

screen shot 2016-02-10 at 10 36 17

@paulrouget
Copy link
Contributor Author

Glutin only send Awakened events during this loop. No other events.

Interesting finding: if I run servo with the option -b, I get the other events (but then rAF runs at 500 FPS). See servo/servo#9431 to understand the difference between the 2 compositing mechanisms.

@paulrouget
Copy link
Contributor Author

@pcwalton any idea of what's going on?

bors-servo pushed a commit to servo/glutin that referenced this issue Feb 29, 2016
cocoa: Post Awakened events at the end of the queue to avoid floods.

Closes servo/webrender#179.

r? @glennw

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/glutin/72)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants