core: Don't use std Instant as it doesn't work for web, use a wrapper

This commit is contained in:
Nathan Adams 2020-10-11 21:10:27 +02:00 committed by Mike Welsh
parent 4abd02e2f7
commit fd6431f724
7 changed files with 15 additions and 5 deletions

6
Cargo.lock generated
View File

@ -1585,6 +1585,11 @@ name = "instant"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485"
dependencies = [
"js-sys",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "iovec"
@ -2682,6 +2687,7 @@ dependencies = [
"generational-arena",
"gif",
"indexmap",
"instant",
"jpeg-decoder",
"json",
"libflate",

View File

@ -32,6 +32,7 @@ thiserror = "1.0"
json = "0.12.4"
chrono = "0.4"
num-traits = "0.2"
instant = "0.1"
[dependencies.jpeg-decoder]
version = "0.1.20"
@ -48,4 +49,5 @@ pretty_assertions = "0.6.1"
[features]
default = ["minimp3"]
lzma = ["swf/lzma"]
wasm-bindgen = [ "instant/wasm-bindgen" ]
avm_debug = []

View File

@ -859,10 +859,11 @@ mod tests {
use crate::tag_utils::{SwfMovie, SwfSlice};
use crate::vminterface::Instantiator;
use gc_arena::rootless_arena;
use instant::Instant;
use rand::{rngs::SmallRng, SeedableRng};
use std::collections::{BTreeMap, HashMap};
use std::sync::Arc;
use std::time::{Duration, Instant};
use std::time::Duration;
fn with_object<F, R>(swf_version: u8, test: F) -> R
where

View File

@ -18,11 +18,11 @@ use crate::prelude::*;
use crate::tag_utils::{SwfMovie, SwfSlice};
use crate::vminterface::Instantiator;
use gc_arena::{rootless_arena, MutationContext};
use instant::Instant;
use rand::{rngs::SmallRng, SeedableRng};
use std::collections::{BTreeMap, HashMap};
use std::sync::Arc;
use std::time::Duration;
use std::time::Instant;
pub fn with_avm<F>(swf_version: u8, test: F)
where

View File

@ -19,11 +19,11 @@ use crate::tag_utils::{SwfMovie, SwfSlice};
use crate::transform::TransformStack;
use core::fmt;
use gc_arena::{Collect, CollectionContext, MutationContext};
use instant::Instant;
use rand::rngs::SmallRng;
use std::collections::{BTreeMap, HashMap, VecDeque};
use std::sync::{Arc, Mutex, Weak};
use std::time::Duration;
use std::time::Instant;
/// `UpdateContext` holds shared data that is used by the various subsystems of Ruffle.
/// `Player` crates this when it begins a tick and passes it through the call stack to

View File

@ -24,13 +24,14 @@ use crate::transform::TransformStack;
use crate::vminterface::Instantiator;
use enumset::EnumSet;
use gc_arena::{make_arena, ArenaParameters, Collect, GcCell};
use instant::Instant;
use log::info;
use rand::{rngs::SmallRng, SeedableRng};
use std::collections::{BTreeMap, HashMap};
use std::convert::TryFrom;
use std::ops::DerefMut;
use std::sync::{Arc, Mutex, Weak};
use std::time::{Duration, Instant};
use std::time::Duration;
pub static DEVICE_FONT_TAG: &[u8] = include_bytes!("../assets/noto-sans-definefont3.bin");

View File

@ -39,7 +39,7 @@ chrono = { version = "0.4", features = ["wasmbind"] }
[dependencies.ruffle_core]
path = "../core"
default-features = false
features = ["puremp3"]
features = ["puremp3", "wasm-bindgen"]
[dependencies.web-sys]
version = "0.3.45"