Merge main into feat/scripts-startup-scripts

This commit is contained in:
dotCooCoo committed 2026-11-25 13:49:06 -08:00
commit 2df812df41
46 files changed
+803 -239

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ log = { workspace = true }
# `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback.
eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] }
# The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft.
craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "6fcf61c816c399508a60c7029a59e2c7b6139e0b", version = "0.1.0" }
craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "b0d422cf0c23baccdaca314b916458a89c0952e0", version = "0.1.0" }
wasm-bindgen = "0.2"
serde_json = { workspace = true }
+29 -2
View File
@@ -398,6 +398,31 @@ pub fn adapter_order(
order.into_iter().map(|(i, _)| i).collect()
}
/// [`adapter_order`] without the adapters a restart left out after they failed (`skip`) and those
/// that crashed an earlier start (`crashed`), and `true` when that left none and the ones that
/// crashed are tried again. A crash record can't stop a start that has no other adapter to try:
/// the record may be from a start ended from outside before its first frame (#9183), which looks
/// the same as a crash in the driver. An adapter in `skip` failed in this run of the app and
/// stays left out.
pub fn order_leaving_out(
candidates: &[Candidate],
power: PowerPreference,
displays: &[DisplayGpu],
compositor: Option<(u32, u32)>,
named: Option<&str>,
skip: &[String],
crashed: &[String],
) -> (Vec<usize>, bool) {
let left_out: Vec<String> = skip.iter().chain(crashed).cloned().collect();
let order = adapter_order(candidates, power, displays, compositor, named, &left_out);
if !order.is_empty() || crashed.is_empty() {
return (order, false);
}
let again = adapter_order(candidates, power, displays, compositor, named, skip);
let retried = !again.is_empty();
(again, retried)
}
/// wgpu's own ranking for a power preference: the preferred kind of GPU, the other kind, unknown,
/// virtual, software.
fn power_rank(t: DeviceType, power: PowerPreference) -> u8 {
@@ -845,10 +870,9 @@ pub fn selector(
) -> NativeAdapterSelectorMethod {
let named = std::env::var(NAME_ENV).ok();
let skip = skipped();
let left_out: Vec<String> = skip.iter().chain(&crashed).cloned().collect();
Arc::new(move |adapters, surface| {
let candidates: Vec<Candidate> = adapters.iter().map(|a| Candidate::new(a, surface)).collect();
let order = adapter_order(&candidates, power, &displays, compositor, named.as_deref(), &left_out);
let (order, retried) = order_leaving_out(&candidates, power, &displays, compositor, named.as_deref(), &skip, &crashed);
let listed: Vec<String> = candidates
.iter()
.map(|c| {
@@ -872,6 +896,9 @@ pub fn selector(
})
.collect();
log::info!("graphics adapters: {}", listed.join("; "));
if retried {
log::warn!("every graphics adapter that can show the window crashed an earlier start: trying them again");
}
let first = order.first().and_then(|&i| adapters.get(i).zip(candidates.get(i)));
let Some((adapter, chosen)) = first else {
startup.none_left();
+14
View File
@@ -827,3 +827,17 @@ fn pci_ids_reject_a_sign_in_the_hex_digits() {
assert_eq!(pci_ids("PCI\\VEN_+10DE&DEV_2204"), None);
assert_eq!(pci_ids("PCI\\VEN_10DE&DEV_+2204"), None);
}
/// #9183: a Mac lists one adapter. A start ended from outside before its first frame left it
/// recorded as crashed, and the next start left it out and had nothing to draw on. It is tried
/// again when nothing else is left; an adapter a restart left out after it failed stays out, and
/// with another adapter to try, the one that crashed is still left out.
#[test]
fn an_adapter_that_crashed_an_earlier_start_is_tried_again_when_no_other_is_left() {
let mac = [gpu("Apple M6", Backend::Metal, DeviceType::IntegratedGpu)];
let crashed = vec![mac[0].key.clone()];
assert_eq!(order_leaving_out(&mac, PowerPreference::LowPower, &[], None, None, &[], &crashed), (vec![0], true));
assert_eq!(order_leaving_out(&mac, PowerPreference::LowPower, &[], None, None, &crashed, &crashed), (vec![], false));
let two = [gpu("Apple M6", Backend::Metal, DeviceType::IntegratedGpu), gpu("llvmpipe", Backend::Gl, DeviceType::Cpu)];
assert_eq!(order_leaving_out(&two, PowerPreference::LowPower, &[], None, None, &[], &crashed), (vec![1], false));
}