bevy/crates
Mike a1d3f1b3b4 Update time by sending frame instant through a channel (#4744)
# Objective

- The time update is currently done in the wrong part of the schedule. For a single frame the current order of things is update input, update time (First stage), other stages, render stage (frame presentation). So when we update the time it includes the input processing of the current frame and the frame presentation of the previous frame. This is a problem when vsync is on. When input processing takes a longer amount of time for a frame, the vsync wait time gets shorter. So when these are not paired correctly we can potentially have a long input processing time added to the normal vsync wait time in the previous frame. This leads to inaccurate frame time reporting and more variance of the time than actually exists. For more details of why this is an issue see the linked issue below.
- Helps with https://github.com/bevyengine/bevy/issues/4669
- Supercedes https://github.com/bevyengine/bevy/pull/4728 and https://github.com/bevyengine/bevy/pull/4735. This PR should be less controversial than those because it doesn't add to the API surface.

## Solution

- The most accurate frame time would come from hardware. We currently don't have access to that for multiple reasons, so the next best thing we can do is measure the frame time as close to frame presentation as possible. This PR gets the Instant::now() for the time immediately after frame presentation in the render system and then sends that time to the app world through a channel.
- implements suggestion from @aevyrie from here https://github.com/bevyengine/bevy/pull/4728#discussion_r872010606

## Statistics

![image](https://user-images.githubusercontent.com/2180432/168410265-f249f66e-ea9d-45d1-b3d8-7207a7bc536c.png)


---

## Changelog

- Make frame time reporting more accurate.

## Migration Guide

`time.delta()` now reports zero for 2 frames on startup instead of 1 frame.
2022-07-11 23:19:00 +00:00
..
bevy_animation Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
bevy_app Remove the dependency cycles (#5171) 2022-07-04 13:04:18 +00:00
bevy_asset Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
bevy_audio Remove the dependency cycles (#5171) 2022-07-04 13:04:18 +00:00
bevy_core Add global init and get accessors for all newtyped TaskPools (#2250) 2022-06-09 02:43:24 +00:00
bevy_core_pipeline Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
bevy_derive android - fix issues other than the rendering (#5130) 2022-06-30 19:42:45 +00:00
bevy_diagnostic Cleanups in diagnostics (#3871) 2022-06-20 17:02:25 +00:00
bevy_dylib Bump Bevy to 0.8.0-dev (#4505) 2022-04-17 23:04:52 +00:00
bevy_dynamic_plugin Bump Bevy to 0.8.0-dev (#4505) 2022-04-17 23:04:52 +00:00
bevy_ecs Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
bevy_ecs_compile_fail_tests Fix rust 1.62 changes (#5154) 2022-06-30 19:24:28 +00:00
bevy_encase_derive Updated glam to 0.21. (#5142) 2022-07-03 19:55:33 +00:00
bevy_gilrs Improve Gamepad DPad Button Detection (#5220) 2022-07-11 14:11:25 +00:00
bevy_gltf Allow rendering meshes without UV coordinate data. (#5222) 2022-07-08 20:55:08 +00:00
bevy_hierarchy Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
bevy_input Improve Gamepad DPad Button Detection (#5220) 2022-07-11 14:11:25 +00:00
bevy_internal enable optional dependencies to stay optional (#5023) 2022-06-20 10:32:43 +00:00
bevy_log Remove the dependency cycles (#5171) 2022-07-04 13:04:18 +00:00
bevy_macro_utils bevy_reflect_derive: Tidying up the code (#4712) 2022-05-12 19:43:23 +00:00
bevy_math Updated glam to 0.21. (#5142) 2022-07-03 19:55:33 +00:00
bevy_mikktspace Updated glam to 0.21. (#5142) 2022-07-03 19:55:33 +00:00
bevy_pbr Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
bevy_ptr add more SAFETY comments and lint for missing ones in bevy_ecs (#4835) 2022-07-04 14:44:24 +00:00
bevy_reflect Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
bevy_render Update time by sending frame instant through a channel (#4744) 2022-07-11 23:19:00 +00:00
bevy_scene Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
bevy_sprite Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
bevy_tasks Miri can set thread names now (#5108) 2022-06-26 21:28:00 +00:00
bevy_text Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
bevy_time Update time by sending frame instant through a channel (#4744) 2022-07-11 23:19:00 +00:00
bevy_transform Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
bevy_ui Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
bevy_utils Document That FloatOrd Implements Hash and Eq Too (#5228) 2022-07-11 14:11:27 +00:00
bevy_window Update codebase to use IntoIterator where possible. (#5269) 2022-07-11 15:28:50 +00:00
bevy_winit Change window position types from tuple to vec (#5276) 2022-07-11 14:36:23 +00:00