From b9bd37a2d444497fb969d5c4404057c2bacd4d44 Mon Sep 17 00:00:00 2001 From: John Nagle Date: Sat, 2 Mar 2024 18:52:04 -0800 Subject: [PATCH] Fix issues #570, #575 (#576) --- .github/workflows/ci.yml | 16 ++++++++-------- rend3-framework/Cargo.toml | 1 - rend3-framework/src/assets.rs | 13 ------------- rend3-framework/src/lib.rs | 22 +++++++++++++++++++--- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51902288..bccbf12a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: - name: Set up Rust toolchain id: setup-rust run: | - rustup toolchain install 1.72 -c clippy -t ${{ matrix.target }} + rustup toolchain install 1.76 -c clippy -t ${{ matrix.target }} - name: Install cargo-nextest and cargo-llvm-cov uses: taiki-e/install-action@v2 @@ -56,21 +56,21 @@ jobs: - name: build run: | - cargo +1.72 build --target ${{ matrix.target }} --profile ci + cargo +1.76 build --target ${{ matrix.target }} --profile ci if: matrix.target != 'wasm32-unknown-unknown' - name: clippy (rend3-gltf featureless) run: | - cargo +1.72 clippy --target ${{ matrix.target }} --profile ci -p rend3-gltf --no-default-features + cargo +1.76 clippy --target ${{ matrix.target }} --profile ci -p rend3-gltf --no-default-features - name: clippy run: | - cargo +1.72 clippy --target ${{ matrix.target }} --profile ci + cargo +1.76 clippy --target ${{ matrix.target }} --profile ci if: matrix.target != 'wasm32-unknown-unknown' - name: doc run: | - cargo +1.72 doc --target ${{ matrix.target }} --profile ci --no-deps + cargo +1.76 doc --target ${{ matrix.target }} --profile ci --no-deps if: matrix.target != 'wasm32-unknown-unknown' - name: download test resources @@ -80,7 +80,7 @@ jobs: - name: test run: | - cargo +1.72 nextest run --target ${{ matrix.target }} --cargo-profile ci --no-fail-fast + cargo +1.76 nextest run --target ${{ matrix.target }} --cargo-profile ci --no-fail-fast if: matrix.target != 'wasm32-unknown-unknown' - uses: actions/upload-artifact@v4 @@ -101,11 +101,11 @@ jobs: - name: Set up Rust toolchain id: setup-rust run: | - rustup toolchain install 1.72 -c rustfmt + rustup toolchain install 1.76 -c rustfmt - name: format run: | - cargo +1.72 fmt --check + cargo +1.76 fmt --check cargo-deny: runs-on: ubuntu-latest diff --git a/rend3-framework/Cargo.toml b/rend3-framework/Cargo.toml index f94063b0..50b17039 100644 --- a/rend3-framework/Cargo.toml +++ b/rend3-framework/Cargo.toml @@ -34,7 +34,6 @@ pollster = "0.3" console_error_panic_hook = "0.1" console_log = "1" js-sys = "0.3" -reqwest = "0.11" once_cell = "1.8" wasm-bindgen = "0.2.87" wasm-bindgen-futures = "0.4" diff --git a/rend3-framework/src/assets.rs b/rend3-framework/src/assets.rs index 2892f8bb..81e09ecd 100644 --- a/rend3-framework/src/assets.rs +++ b/rend3-framework/src/assets.rs @@ -12,19 +12,6 @@ pub enum AssetError { #[source] error: std::io::Error, }, - #[error("Could not read {path} from the network")] - #[cfg(target_arch = "wasm32")] - NetworkError { - path: SsoString, - #[source] - error: reqwest::Error, - }, - #[error("Reading {path} from the network returned non-success status code {status}")] - #[cfg(target_arch = "wasm32")] - NetworkStatusError { - path: SsoString, - status: reqwest::StatusCode, - }, } pub enum AssetPath<'a> { diff --git a/rend3-framework/src/lib.rs b/rend3-framework/src/lib.rs index 1f4b2344..188a4417 100644 --- a/rend3-framework/src/lib.rs +++ b/rend3-framework/src/lib.rs @@ -71,10 +71,14 @@ pub trait App { console_log::init().unwrap(); #[cfg(all(not(target_arch = "wasm32"), not(target_os = "android")))] - env_logger::builder() + if let Err(e) = env_logger::builder() .filter_module("rend3", log::LevelFilter::Info) .parse_default_env() - .init(); + .try_init() + { + eprintln!("Error registering logger from Rend3 framework: {:?}", e); + // probably ran two runs in sequence and initialized twice + }; } fn register_panic_hook(&mut self) { @@ -134,15 +138,27 @@ pub trait App { 1.0 } + /// Set up the rendering environment. Called once at startup. fn setup(&mut self, context: SetupContext<'_, T>) { let _ = context; } + /// Handle a non-redraw event. fn handle_event(&mut self, context: EventContext<'_, T>, event: Event) { let _ = (context, event); } + /// Handle a redraw event. fn handle_redraw(&mut self, context: RedrawContext<'_, T>); + + /// Called after each redraw for post-processing, if needed. + /// By default, this queues another redraw. + /// That behavior is not appropriate on some platforms. + /// Ref: Issue 570. + /// This gives the application the option of overriding that behavior. + fn handle_redraw_done(&mut self, window: &Window) { + window.request_redraw(); // just queue a redraw. + } } pub fn lock(lock: &parking_lot::Mutex) -> parking_lot::MutexGuard<'_, T> { @@ -369,7 +385,7 @@ pub async fn async_start + 'static, T: 'static>(mut app: A, window_bui surface_texture.present(); - window.request_redraw(); + app.handle_redraw_done(&window); // standard action is to redraw, but that can be overridden. } else { app.handle_event( EventContext {