Replies: 1 comment
-
The real problem was that I was using |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am on a side quest trying to port some code from another project that used Bevy 0.16.0.
The code is responsible for setting the icons for individual windows.
Here, we see an example where the icon for the window itself is unset.
The code for Bevy 0.16.0 used
windows: NonSend<WinitWindows>,
to get access to theWindowWrapper<Window>
corresponding to theEntity
of a window.I defined a custom component for making it easy to set the icon for a window.
https://github.com/TeamDman/youre-muted-btw/blob/4783e1efe184083b053882cc066c9932588551c5/crates/window_icon_plugin/src/lib.rs
In Bevy
0.17.0-rc.1
, theNonSend<WinitWindows>
has been replaced with athread_local!
WINIT_WINDOWS
#19575
I have since rewritten my logic for setting the custom window icon
https://github.com/TeamDman/teamy-mft/blob/2a073c6101a1f6ac8060aa60ce127a64661a5127/src/engine/window_icon_plugin.rs
However, this panics.
Simplifying the system, it still panicks.
unless I disable the system all together, which doesn't really help lol
// app.add_systems(UpdateWindowIconsSchedule, set_window_icon); // disabled
The migration guide mentions
bevy/release-content/migration-guides/replace_non_send_resources.md
Line 48 in 2451112
which makes sense.
Because it is a thread-local variable, I've included
_main_thread_marker: NonSendMarker,
in the system to ensure we get the correctWINIT_WINDOWS
.Because it is a
RefCell
, to try and guarantee non-contentious access, I've tried adding my own schedule which to my understanding means that nothing else will run at the same time.I've tried commenting out the
set_executor_kind
in my custom schedule// custom_update_schedule.set_executor_kind(ExecutorKind::SingleThreaded);
I've tried running in Last
From what I can tell, the Bevy logic is running in
Last
bevy/crates/bevy_winit/src/lib.rs
Lines 138 to 149 in 2451112
and it immediately borrows WINIT_WINDOWS
bevy/crates/bevy_winit/src/system.rs
Lines 569 to 581 in 2451112
...
And it is at this point that I realized the problem and thus the fix
I don't need a mutable borrow at all!
All is well now :D
Beta Was this translation helpful? Give feedback.
All reactions