From 716a0253529ac116294ad157dc58da97474b8917 Mon Sep 17 00:00:00 2001 From: funman300 Date: Fri, 8 May 2026 11:09:27 -0700 Subject: [PATCH] fix(app): wrap WinitWindows in Option to satisfy Bevy 0.18 param validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `NonSend` failed system-param validation on the first few frames before `WinitWindows` was populated, panicking the Update system before any logic could run. Bevy 0.18's stricter validation panics rather than skips when a non-send resource is absent, with an error message spelling out the fix: *"wrap the parameter in `Option` and handle `None` when it happens."* Wraps `winit_windows` as `Option>` and early-returns on `None`, mirroring the same lifecycle handling already applied to `winit_windows.get_window(primary_entity)` — both fail in the same window of frames before winit's `Resumed` event fires. Repro from the user's `cargo run` log: ``` thread 'Compute Task Pool (2)' panicked at .../bevy_ecs-0.18.1/src/error/handler.rs:125:1: Encountered an error in system ...: Parameter ... failed validation: Non-send resource does not exist ``` Workspace clippy + cargo test --workspace clean, 1185 passing. Co-Authored-By: Claude Opus 4.7 --- solitaire_app/src/lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/solitaire_app/src/lib.rs b/solitaire_app/src/lib.rs index 06650f5..6115008 100644 --- a/solitaire_app/src/lib.rs +++ b/solitaire_app/src/lib.rs @@ -284,11 +284,20 @@ fn apply_smart_default_window_size( fn set_window_icon( mut applied: Local, primary_window: Query>, - winit_windows: NonSend, + // `Option>` rather than `NonSend<...>` because Bevy + // 0.18's stricter system-param validation panics on the first + // few frames before `WinitWindows` is inserted (the resource is + // populated after winit's `Resumed` event, which fires after + // the first system-tick batch). The early-return below handles + // the `None` window-wrapper case for the same lifecycle reason. + winit_windows: Option>, ) { if *applied { return; } + let Some(winit_windows) = winit_windows else { + return; + }; let Ok(primary_entity) = primary_window.single() else { return; };