Skip to content

Commit

Permalink
Fix CI freezing (#53)
Browse files Browse the repository at this point in the history
In my haste to try to work on Gooey last night, I published a kludgine update without waiting for CI to finish. After both Kludgine and Gooey's CI timed out, I launched the investigation.

In the end there is a "fix" -- I think the old code (while amateurish with its usage of boxing futures and fusing, which are unnecessary here I now know) was technically more correct than what is happening here. I put in an issue for the wgpu developers to see: gfx-rs/wgpu#2266.

This also overhauls the CI workflows so that they're split. The dependencies have been switched to those that are in the wgpu repository's workflows.
  • Loading branch information
ecton authored Dec 8, 2021
1 parent 6675a86 commit c663ad3
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 86 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Audit

on: [push]

jobs:
audit:
runs-on: ubuntu-latest

steps:
- name: Install Rust
uses: hecrj/setup-rust-action@v1
- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin/cargo-audit
key: cargo-audit
- name: Install cargo-audit
run: cargo -v install cargo-audit
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ matrix.branch }}
- name: Audit
# RUSTSEC-2021-0119: indirect dependency, nix https://github.com/nix-rust/nix/issues/1541
run: |
cargo audit -D warnings --ignore RUSTSEC-2021-0119
10 changes: 4 additions & 6 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ jobs:
- name: Install x11 dependencies for Kludgine
run: |
sudo apt-get update -y -qq
sudo add-apt-repository ppa:kisak/kisak-mesa -y
sudo apt-get install -yqq \
libxcb-render-util0-dev \
libxcb-shape0-dev \
libxcb-xfixes0-dev \
mesa-vulkan-drivers
sudo add-apt-repository ppa:oibaf/graphics-drivers -y
sudo apt-get update
sudo apt-get install -y \
libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- name: Run code coverage
run: |
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Docs

on: [push]

jobs:
docs:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2

- name: Install x11 dependencies for Kludgine
run: |
sudo apt-get update -y -qq
sudo add-apt-repository ppa:oibaf/graphics-drivers -y
sudo apt-get update
sudo apt-get install -y \
libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- name: Generate Docs
run: |
cargo doc --no-deps --all-features
- name: Deploy Docs
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
branch: gh-pages
folder: target/doc/
git-config-name: kl-botsu
git-config-email: [email protected]
target-folder: /main/
clean: true
66 changes: 4 additions & 62 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,6 @@ name: Tests
on: [push]

jobs:
audit:
runs-on: ubuntu-latest

steps:
- name: Install Rust
uses: hecrj/setup-rust-action@v1
- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin/cargo-audit
key: cargo-audit
- name: Install cargo-audit
run: cargo -v install cargo-audit
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ matrix.branch }}
- name: Audit
# RUSTSEC-2021-0090: indirect dependency, ash https://github.com/MaikKlein/ash/issues/354
run: |
cargo audit -D warnings --ignore RUSTSEC-2021-0090
test:
runs-on: ubuntu-latest
steps:
Expand All @@ -37,12 +11,10 @@ jobs:
- name: Install x11 dependencies for Kludgine
run: |
sudo apt-get update -y -qq
sudo add-apt-repository ppa:kisak/kisak-mesa -y
sudo apt-get install -yqq \
libxcb-render-util0-dev \
libxcb-shape0-dev \
libxcb-xfixes0-dev \
mesa-vulkan-drivers
sudo add-apt-repository ppa:oibaf/graphics-drivers -y
sudo apt-get update
sudo apt-get install -y \
libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- name: Run clippy
run: |
Expand All @@ -53,33 +25,3 @@ jobs:
- name: Run tokio unit tests
run: |
cargo test --no-default-features --features="tokio-rt"
docs:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2

- name: Install x11 dependencies for Kludgine
run: |
sudo apt-get update -y -qq
sudo add-apt-repository ppa:kisak/kisak-mesa -y
sudo apt-get install -yqq \
libxcb-render-util0-dev \
libxcb-shape0-dev \
libxcb-xfixes0-dev \
mesa-vulkan-drivers
- name: Generate Docs
run: |
cargo doc --no-deps --all-features
- name: Deploy Docs
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
branch: gh-pages
folder: target/doc/
git-config-name: kl-botsu
git-config-email: [email protected]
target-folder: /main/
clean: true
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## v0.1.0-dev.5

### Added
### Changed

- Updated dependencies for compatability with wgpu 0.11.1.
- Implemented Sprite alpha rendering. The APIs already existed, but the alpha value was being ignored.
Expand Down
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ tracing-futures = { version = "0.2" }
[dev-dependencies]
tokio = { version = "1.0", features = ["full"] }
image = { version = ">=0.23.12", default-features = false, features = ["png"] }
tracing-subscriber = "0.3"
4 changes: 4 additions & 0 deletions core/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use easygpu::wgpu::BufferAsyncError;
use easygpu_lyon::lyon_tessellation::TessellationError;

/// All errors that `kludgine-core` can return.
Expand All @@ -18,4 +19,7 @@ pub enum Error {
/// The sprite's current tag has no frames.
#[error("no frames could be found for the current tag")]
InvalidSpriteTag,
/// An error occurred during offscreen rendering.
#[error("error acquiring offscreen buffer: {0}")]
Offscreen(#[from] BufferAsyncError),
}
29 changes: 12 additions & 17 deletions core/src/frame_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ use easygpu::{
};
use easygpu_lyon::LyonPipeline;
use figures::Rectlike;
use futures::FutureExt;
use image::DynamicImage;
use instant::Duration;

use crate::{
delay,
math::{ExtentsRect, Point, Size, Unknown},
scene::SceneEvent,
sprite::{self, VertexShaderSource},
Expand Down Expand Up @@ -142,21 +139,19 @@ where
frame_renderer.render_frame(&mut frame)?;
if let Destination::Texture { output, .. } = frame_renderer.destination {
let data = output.slice(..);
let mut map_async = Box::pin(data.map_async(wgpu::MapMode::Read).fuse());
let map_async = data.map_async(wgpu::MapMode::Read);
let wgpu_device = frame_renderer.renderer.device.wgpu;
let mut poll_loop = Box::pin(
async move {
loop {
wgpu_device.poll(wgpu::Maintain::Poll);
delay::Delay::new(Duration::from_millis(1)).await;
}
}
.fuse(),
);
while futures::select! {
_ = map_async => false,
_ = poll_loop => true,
} {}
// TODO this is what the wgpu example does, and it appears to work
// in CI. Originally, this code tried to be fancy and had a loop
// calling Maintain::Poll and delaying inbetween invocations, but it
// locked up under CI -- the buffer map call never returned. This
// method is technically blocking, but it's blocking on hardware.
// Additionally, when doing an offscreen render, I'm not sure how
// impactful it really is to the async runtime to block here. This
// theoretically should be moved to a blocking-aware call, but
// currently kludgine-core is runtime agnostic.
wgpu_device.poll(wgpu::Maintain::Wait);
map_async.await?;

let bytes = data.get_mapped_range().to_vec();

Expand Down
4 changes: 4 additions & 0 deletions core/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
use easygpu::wgpu;
use image::{GenericImageView, Rgba};
use tracing::Level;
use winit::window::Theme;

use crate::{frame_renderer::FrameRenderer, prelude::*, sprite::Srgb};

#[tokio::test]
#[allow(clippy::semicolon_if_nothing_returned)] // false positive from tokio::test
async fn offscreen_render_test() {
tracing_subscriber::fmt()
.with_max_level(Level::TRACE)
.init();
let (scene_sender, scene_receiver) = flume::unbounded();

let instance = wgpu::Instance::new(wgpu::Backends::PRIMARY);
Expand Down

0 comments on commit c663ad3

Please sign in to comment.