-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking: bevy-trait-query
breakage after changes to WorldQuery
API
#13798
Comments
@JoJoJet @hymm @james7132 @Victoronz @james-j-obrien: bringing this to your attention. We should figure out how to address this without reintroducing the UB (or potential for similar UB). |
The simplest fix would be to revert the |
That won't fix this issue. The breakage here is that retrieving |
Can we pass an edit: This would allow bevy_trait_query to register a read on the resource it needs. So that the system param does have access to get the resource from the UnsafeWorldCell. Maybe? Can QueryData register a read on a resource? |
|
Passing an |
It wouldn't be UB as long as you use the unsafe methods on UnsafeWorldCell to access the resource and the read on the resource is correctly registered. |
Is it possible to bubble up the read on the resource to the containing system properly? If so, I think passing in an additional |
While technically possible, how does a user or library author ensure the safety here? If a different system wishes to access a parameter mutably, then it is now up to the user to schedule this out of each others way. This would mean we say, "If you wish to |
I wonder, could a third *_state method be added that is explicitly unsafe? This would make more sense than changing the safe methods for this IMO |
|
There currently is no API to retrieve |
Hmm. So I tried to change to The other option is to just revert the I think someone should probably make the pr to revert the init_state change, since that would be needed for either approach. |
#13804) …izer (#13442)" This reverts commit 5cfb063. - This PR broke bevy-trait-query, which needs to be able to write a resource in init_state. See #13798 for more details. - Note this doesn't fix everything as transmutes for bevy-trait-query will still be broken,. But the current usage in that crate is UB, so we need to find another solution.
#13804) …izer (#13442)" This reverts commit 5cfb063. - This PR broke bevy-trait-query, which needs to be able to write a resource in init_state. See #13798 for more details. - Note this doesn't fix everything as transmutes for bevy-trait-query will still be broken,. But the current usage in that crate is UB, so we need to find another solution.
This has been reverted: I'm going to close this and continue the discussion in #13358 |
@alice-i-cecile Wasn't this revert only one part of the issue? The revert provided a workaround for |
The issue
At some point (#13442, #13343) the
WorldQuery
API was changed from this ... to this. Most notably, the function signature ofinit_state
andget_state
changed which didn't cause any direct problems in the bevy repo itself.However, it seems like at least one downstream crate,
bevy-trait-query
, depends on the previous version of this API to access a vital building block: TheTraitImplRegistry
resource. This was previously possible through the&mut World
argument and now isn't possible anymore. It also doesn't appear to be easily fixable with the current API.Alice also mentioned that things like indexed queries wouldn't be possible anymore without access to resources.
The text was updated successfully, but these errors were encountered: