bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.42k stars 3.59k forks source link

Events<GamepadEventRaw> appears to be getting updated twice per world tick (gilrs) #2893

Closed CAD97 closed 3 years ago

CAD97 commented 3 years ago

Bevy version

git master

What you did

Looked at the code (I'm playing around with building a custom mini engine using bevy ECS, for learning purposes).

What you expected to happen

Events::update says it should be called once per tick, to manage the double buffer correctly.

What actually happened

update appears to be getting called twice per tick:

Additional information

It's possible I'm just misunderstanding what's going on here, but this seems wrong at first glance. At the very least, the update call in bevy_gilrs probably deserves a comment calling out that it's a second update call in the simulation tick explaining why we want to discard the double buffer in this case.

alice-i-cecile commented 3 years ago

Good find. These events should not be cleared twice. Removing the update from gilrs is the correct way to fix this.

Incidentally, that system looks like it no longer need to be exclusive: we should fix that in the same PR.

CAD97 commented 3 years ago

AIUI systems that access non-send resources (like Gilrs is) still need to be exclusive. Or if they don't, I didn't find the correct way to request access.

alice-i-cecile commented 3 years ago

Nope, they'll work fine in ordinary systems :) Just use NonSend as a system parameter.