Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,8 @@ jobs:
grep -h -E "^self-test" "$RUNNER_TEMP/selftest.log" "$RUNNER_TEMP/selftest-audio.log"
if [ "$shot_status" -ne 0 ] || [ ! -s app-linux.png ]; then echo "::error title=Screenshot failed (Linux)::exit status $shot_status"; exit 1; fi
[ "$plain_status" -eq 0 ] && [ "$audio_status" -eq 0 ]
# Windows exits with code 0x87A after a run that passed (not yet
# explained, see engine/README.md), so the exit code is printed but not
# checked; a missing screenshot or self-test summary, or a failed check,
# fails the step.
# A non-zero exit code, a missing screenshot or self-test summary, or a
# failed check fails the step.
- name: App — screenshot (Windows, WARP)
if: runner.os == 'Windows' && steps.changes.outputs.run == 'true'
timeout-minutes: 5
Expand All @@ -484,6 +482,7 @@ jobs:
Get-Content shot-windows-stderr.txt
"screenshot run exit code: 0x{0:X8}" -f $p.ExitCode
if (-not (Test-Path app-windows.png)) { throw "no screenshot" }
if ($p.ExitCode -ne 0) { throw "the app exited with 0x{0:X8}" -f $p.ExitCode }
# The full self-test under WARP takes about 30 minutes (the software
# renderer is capped at two frames in flight so it no longer runs out of
# memory), so pull requests skip it unless they carry the
Expand Down Expand Up @@ -511,6 +510,7 @@ jobs:
if (-not $line) { Get-Content selftest-windows-stderr.txt -Tail 30; throw "no self-test summary" }
$line.Value
if ($line.Groups[1].Value -ne $line.Groups[2].Value) { throw "self-test failures" }
if ($p.ExitCode -ne 0) { throw "the self-test passed but the app exited with 0x{0:X8}" -f $p.ExitCode }
- name: Upload app screenshots and self-test logs
if: steps.changes.outputs.run == 'true' && !cancelled()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ jobs:
$p = Start-Process -FilePath (Join-Path $dir 'device-studio.exe') -ArgumentList '--state', 'reference-default', '--screenshot', $shot -NoNewWindow -Wait -PassThru
"exit code: 0x{0:X8}" -f $p.ExitCode
if (-not (Test-Path $shot)) { throw "the installed app did not render" }
if ($p.ExitCode -ne 0) { throw "the installed app exited with 0x{0:X8}" -f $p.ExitCode }
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: package-windows
Expand Down
39 changes: 35 additions & 4 deletions crates/dstudio-app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,10 +945,41 @@ fn synth_test_state(device: dstudio_core::DeviceId) -> dstudio_core::Command {
}

fn main() {
if let Err(e) = run() {
eprintln!("device-studio: {e}");
std::process::exit(1);
}
let code = match run() {
Ok(()) => 0,
Err(e) => {
eprintln!("device-studio: {e}");
1
}
};
exit_now(code);
}

/// End the process with `code` once `run` has returned and everything it owns is dropped.
///
/// On Windows a normal exit (returning from `main`, or `std::process::exit`) reported
/// 0x87A instead of our code after any run that had opened the window: something in the
/// graphics stack ends the process with its own code while its DLLs unload, with the wgpu
/// device still alive in Slint's thread-local backend. Nothing of ours is left to run at
/// that point (the project, settings and engine are closed inside `run`), so the process
/// is ended directly, which skips DLL unloading and gives the caller the real result.
#[cfg(windows)]
fn exit_now(code: i32) -> ! {
use std::io::Write;
unsafe extern "system" {
fn GetCurrentProcess() -> *mut std::ffi::c_void;
fn TerminateProcess(process: *mut std::ffi::c_void, exit_code: u32) -> i32;
}
let _ = std::io::stdout().flush();
let _ = std::io::stderr().flush();
// SAFETY: both calls take no pointers from us; the pseudo-handle is always valid.
unsafe { TerminateProcess(GetCurrentProcess(), code as u32) };
std::process::exit(code)
}

#[cfg(not(windows))]
fn exit_now(code: i32) -> ! {
std::process::exit(code)
}

/// AppKit adds Start Dictation, Emoji & Symbols and Enter Full Screen to any Edit and View
Expand Down
10 changes: 7 additions & 3 deletions engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,13 @@ without a GPU or audio device: on Linux under Xvfb with Mesa lavapipe (software
are reported as skipped off macOS), as a required step; on Windows with WARP
(DX12 software adapter) the same, also failing the job when a check fails (the
full self-test runs on main, nightly and labelled pull requests that change
the app; see docs/building.md): the screenshot renders and the self-test passes, but the
process exits with code 0x87A after the run (not yet explained; macOS/Linux
exit 0), so CI prints that exit code and checks the summary line instead.
the app; see docs/building.md): the screenshot renders, the self-test passes and the
exit code is checked on all three systems. On Windows the app ends its process directly
once `run` has returned (`exit_now` in `crates/dstudio-app/src/main.rs`): with a normal
exit, any run that had opened the window reported 0x87A instead of our code. The code is
set after `main` returns, while the process unloads its DLLs, with or without audio, a
screenshot or presented frames; a run that exits before the window exists returns 0.
Seen with WARP on the hosted runner; not yet checked on a real GPU.
Debug builds of the app abort at exit on every OS (pre-existing: wgpu-core's
debug-only lock tracing runs in a TLS destructor when Slint's thread-local
backend drops the wgpu queue), so CI uses a release build. Screenshots and logs are uploaded as artifacts.
Expand Down
Loading