[oden] Tracing and also actual 60fps
Sleeping is completely and utterly unreliable.
This commit is contained in:
parent
b149b28f31
commit
734a1279a6
4 changed files with 237 additions and 42 deletions
|
|
@ -5,6 +5,7 @@ use oden_js::{
|
|||
use std::ffi::OsStr;
|
||||
use std::sync::mpsc::{channel, Receiver};
|
||||
use std::time::Instant;
|
||||
use tracy_client::span;
|
||||
|
||||
pub mod graphics;
|
||||
use graphics::GraphicsCommand;
|
||||
|
|
@ -99,29 +100,41 @@ impl ScriptContext {
|
|||
// game thread go to fast probably? And to discard whole frames &c.
|
||||
|
||||
pub fn init(&mut self) {
|
||||
let _span = span!("script init");
|
||||
|
||||
self.init
|
||||
.call(&self.context, &[])
|
||||
.expect("Exception in init");
|
||||
}
|
||||
|
||||
pub fn update(&mut self) {
|
||||
let _span = span!("script update");
|
||||
|
||||
// Do we update the frame time before of after async completion?
|
||||
// Hmmmmm.
|
||||
self.time.set_frame_time(Instant::now());
|
||||
|
||||
// Tell the runtime to process all pending "jobs". This includes
|
||||
// promise completions.
|
||||
self.context
|
||||
.process_all_jobs()
|
||||
.expect("Error processing async jobs");
|
||||
{
|
||||
let _span = span!("process jobs");
|
||||
self.context
|
||||
.process_all_jobs()
|
||||
.expect("Error processing async jobs");
|
||||
}
|
||||
|
||||
// Now run the update function.
|
||||
self.update
|
||||
.call(&self.context, &[])
|
||||
.expect("Exception in update");
|
||||
{
|
||||
let _span = span!("javascript update");
|
||||
self.update
|
||||
.call(&self.context, &[])
|
||||
.expect("Exception in update");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render(&mut self) -> Vec<graphics::GraphicsCommand> {
|
||||
let _span = span!("script render");
|
||||
|
||||
self.draw
|
||||
.call(&self.context, &[])
|
||||
.expect("Exception in draw");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue