Skip to content
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

Spawning scenes with cameras no longer works #11852

Closed
cart opened this issue Feb 13, 2024 · 10 comments · Fixed by #11878
Closed

Spawning scenes with cameras no longer works #11852

cart opened this issue Feb 13, 2024 · 10 comments · Fixed by #11878
Labels
A-Scenes Serialized ECS data stored on the disk C-Bug An unexpected or incorrect behavior P-High This is particularly urgent, and deserves immediate attention
Milestone

Comments

@cart
Copy link
Member

cart commented Feb 13, 2024

Bevy version

77c26f6

What you did

Exported a GLTF scene from Blender with a camera and loaded it in Bevy.

What went wrong

The app crashed because CameraRenderGraph does not implement Reflect. This regressed in #10644.
For future reference, removing Reflect from a type that exists in a bundle used in scenes should almost never be allowed.

@cart cart added C-Bug An unexpected or incorrect behavior A-Scenes Serialized ECS data stored on the disk labels Feb 13, 2024
@cart cart added this to the 0.13 milestone Feb 13, 2024
@alice-i-cecile
Copy link
Member

I think we should fix this for 0.13.

@cart
Copy link
Member Author

cart commented Feb 13, 2024

Reverting #10644 isn't enough because this also doesn't implement Reflect: #11412

@alice-i-cecile
Copy link
Member

Can/should we derive Reflect on our bundle types to more easily catch these errors?

@cart
Copy link
Member Author

cart commented Feb 13, 2024

Yeah I think thats a good call. Probably not for 0.13 though.

@DasLixou
Copy link
Contributor

Should we just enforce labels to derive reflect and then we reflect them via their path?

@cart
Copy link
Member Author

cart commented Feb 13, 2024

Alrighty after reverting #10644 and adding a reflect_value impl to wgpu::TextureUsages in bevy_reflect, deriving Reflect on CameraMainTextureUsages, and registering the type, we're back in business:

use crate as bevy_reflect;

use bevy_reflect_derive::impl_reflect_value;

impl_reflect_value!(::wgpu::TextureUsages(Debug, Hash, PartialEq));

image

It is broken for serialization scenarios (as TextureUsages is not serializable). But it fixes GLTF loading. I'm going to see if we can do the same reflect_value hack for #10644 to avoid needing to revert (but note that us moving away from strings for this will break serialization for that as well).

The TextureUsages serialization can be fixed by moving to the Image mirror types we'll be adding here: #11294 (comment)

Should we just enforce labels to derive reflect and then we reflect them via their path?

The interned RenderGraph label serialization will be its own can of worms as we've moved to using types as identifiers. We'd likely need some type of TypePath -> label object registry for this. My new scene system would accommodate this type of exchange by supporting constructing the runtime types from different types in the scene, with access to a World context. (aka use the TypePath in the scene to grab the TypePath->Object mapping from a resource when spawning).

@cart
Copy link
Member Author

cart commented Feb 13, 2024

Arg adding wgpu to bevy_reflect puts it much earlier in the dependency tree. I'm getting a ~7 second clean compile time regression (on my fast computer that compiles main in ~30 seconds, so that will be magnified on the average computer).

@IceSentry
Copy link
Contributor

Sorry about #11412 not implementing reflect. I noticed the issue a while ago but completely forgot about fixing it or mentioning it. But yeah, should be easy enough to just impl Reflect for it.

@IceSentry
Copy link
Contributor

Arg adding wgpu to bevy_reflect puts it much earlier in the dependency tree. I'm getting a ~7 second clean compile time regression (on my fast computer that compiles main in ~30 seconds, so that will be magnified on the average computer).

Maybe we should define a custom bevy enum that is easy to reflect and match on it when we need the wgpu type?

@james7132 james7132 added the P-High This is particularly urgent, and deserves immediate attention label Feb 13, 2024
@cart
Copy link
Member Author

cart commented Feb 14, 2024

Maybe we should define a custom bevy enum that is easy to reflect and match on it when we need the wgpu type?

Yeah thats where my head is at as well / what I was getting at with this comment:

The TextureUsages serialization can be fixed by moving to the Image mirror types we'll be adding here: #11294 (comment)

github-merge-queue bot pushed a commit that referenced this issue Feb 15, 2024
…raMainTextureUsages (#11878)

# Objective

The new render graph labels do not (and cannot) implement normal
Reflect, which breaks spawning scenes with cameras (including GLTF
scenes). Likewise, the new `CameraMainTextureUsages` also does not (and
cannot) implement normal Reflect because it uses `wgpu::TextureUsages`
under the hood.

Fixes #11852

## Solution

This implements minimal "reflect value" for `CameraRenderGraph` and
`CameraMainTextureUsages` and registers the types, which satisfies our
spawn logic.

Note that this _does not_ fix scene serialization for these types, which
will require more significant changes. We will especially need to think
about how (and if) "interned labels" will fit into the scene system. For
the purposes of 0.13, I think this is the best we can do. Given that
this serialization issue is prevalent throughout Bevy atm, I'm ok with
adding a couple more to the pile. When we roll out the new scene system,
we will be forced to solve these on a case-by-case basis.

---

## Changelog

- Implement Reflect (value) for `CameraMainTextureUsages` and
`CameraRenderGraph`, and register those types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Scenes Serialized ECS data stored on the disk C-Bug An unexpected or incorrect behavior P-High This is particularly urgent, and deserves immediate attention
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants