Skip to content

WinitWindows resource never exists? #23860

Description

@FeatheredOrbit

Bevy version and features

bevy = {version = "0.18.1", default-features = true}

[Optional] Relevant system information

Linux Mint 22.3
X11

What you did

Tried to access NonSend<WinitWindows> so that I could get monitor size but instead causes a panic:

thread 'main' (55315) panicked at /home/chickenultra/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_ecs-0.18.1/src/error/handler.rs:125:1:
Encountered an error in system `<Enable the debug feature to see the name>`: Parameter `<Enable the debug feature to see the name>` failed validation: Non-send resource does not exist
If this is an expected state, wrap the parameter in `Option<T>` and handle `None` when it happens, or wrap the parameter in `If<T>` to skip the system when it happens. 

If I try and wrap it in option and print the result of .is_some(), it will always print false even with the windows blatantly on screen.

Additional information

I've made an example that, at least for me, always results in Option<NonSend<WinitWindows>> being None. It starts off with the primary window created with the WindowPlugin in DefaultPlugins, and then after 5 seconds it creates one via command, all while check_winit_windows prints if its Some or None.

use bevy::{prelude::*, window::WindowResolution, winit::WinitWindows};

fn main() {
    App::new()
    .add_plugins(DefaultPlugins.set(WindowPlugin {
        primary_window: Some(Window {
            title: "I'm litterally a window".to_string(),
            resolution: WindowResolution::new(600, 600),
            ..Default::default()
        }),

        ..Default::default()
    }))

    .add_systems(Update, add_new_window)

    .add_systems(Update, check_winit_windows)
    
    .run();
}

fn check_winit_windows(
    winit_windows: Option<NonSend<WinitWindows>>
) {
    println!("{}", winit_windows.is_some());
}

fn add_new_window(
    time: Res<Time>,
    mut commands: Commands,
    query: Query<&SecondWindow>
) {
    if time.elapsed_secs() < 5.0 || query.count() > 0 { return }

     
    commands.spawn(
        Window {
            title: "I'm also litterally a window".to_string(),
            resolution: WindowResolution::new(800, 800),
            ..Default::default()
        }
        
    );

    commands.spawn(SecondWindow);
    
}

#[derive(Component)]
struct SecondWindow; 

Like said on top this was made with bevy version 0.18.1 with default features, but I "discovered" this issue with only default_app and default_platform, though I don't think its relevant. Idk if thats the wrong way of getting WinitWindows, everywhere I looked they do it like that, so I don't know what's wrong.

Activity

  1. converted this issue into a discussion #23861 on Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-BugAn unexpected or incorrect behaviorS-Needs-TriageThis issue needs to be labelled

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions