Skip to content

Fix Limiter::Auto not working with bevy 0.17.0#71

Merged
aevyrie merged 4 commits into
aevyrie:mainfrom
NorthropBtwo:main
Dec 8, 2025
Merged

Fix Limiter::Auto not working with bevy 0.17.0#71
aevyrie merged 4 commits into
aevyrie:mainfrom
NorthropBtwo:main

Conversation

@NorthropBtwo
Copy link
Copy Markdown
Contributor

As described in #69, WINIT_WINDOWS.with_borrow must be called from the bevy main thread.

@NorthropBtwo
Copy link
Copy Markdown
Contributor Author

Hi! GitHub Actions did not trigger because this PR is from a fork. Could someone approve the workflow run?

Comment thread src/lib.rs Outdated
#[cfg(not(target_arch = "wasm32"))]
use bevy_winit::WINIT_WINDOWS;
#[cfg(not(target_arch = "wasm32"))]
use std::cell::Cell;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be moved into a full path where Cell is used, instead of a new gated import?

Comment thread src/lib.rs Outdated
settings: Res<FramepaceSettings>,
windows: Query<Entity, With<Window>>,
frame_limit: Res<FrametimeLimit>,
_token: NonSend<MainThreadToken>,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need a new type here? Can you just use NonSend<()>?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. NonSend<()> would work but then we have to insert an empty resource like this: .insert_non_send_resource(()). This is a bit clunky because the empty resource can be removed by another library and the programm would crash. I suggest using Option<NonSend<()>>. This would make the solution trivial. There is no need to insert a resource and it still does the trick.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, the Bevy migration docs indicate that accepting a bevy_ecs::system::NonSendMarker input param would be the conventional mechanism to achieve this.

https://bevy.org/learn/migration-guides/0-16-to-0-17/#nonsend-systems

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bevy_ecs::system::NonSendMarker appears to be the official Bevy mechanism. Thanks for pointing that out. I have updated the PR accordingly.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Feel free to poke me on the bevy discord in the future if I am slow to respond.

Comment thread src/lib.rs
settings: Res<FramepaceSettings>,
windows: Query<Entity, With<Window>>,
frame_limit: Res<FrametimeLimit>,
_non_send_marker: NonSendMarker, // This system may call WINIT_WINDOWS.with_borrow indirectly which requires the system runs on the Bevy main thread.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you just use the full path here instead of adding a feature gated import up top?

@aevyrie aevyrie enabled auto-merge (squash) December 8, 2025 18:06
@aevyrie aevyrie merged commit 4fa249c into aevyrie:main Dec 8, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants