#Serializing Scenes error from AtomicBool

33 messages · Page 1 of 1 (latest)

worthy monolith
#

Bevy 0.17.3 (downgraded to use Rapier)

The following code:


fn main() {
    App::new()
        .insert_resource(ClearColor(Color::linear_rgb(0.2, 0.4, 1.0)))
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, save_scene)
        .run();
}

fn save_scene(world: &mut World) {
    let registry = world.resource::<AppTypeRegistry>();
    let scene = DynamicScene::from_world(world);
    let serialized_scene = scene.serialize(&registry.read());
    info!("{:?}", serialized_scene);
}```

Results in the following error:
```type `bevy_platform::sync::Arc<core::sync::atomic::AtomicBool>` did not register the `ReflectSerialize` or `ReflectSerializeWithRegistry` type data. For certain types, this may need to be registered manually using `register_type_data` (stack: `bevy_a11y::AccessibilityRequested` -> `bevy_platform::sync::Arc<core::sync::atomic::AtomicBool>`)```

I don't really know where the call to AtomicBool comes from, and I'm trying to find a workaround.

I have found a relevant github issue (https://github.com/bevyengine/bevy/issues/22816), but can anyone help me find a workaround in the meantime?
GitHub

A refreshingly simple data-driven game engine built in Rust - bevyengine/bevy

magic haven
#

Do you know where that atomic is being used in your stack? It’s most likely UI. You could maybe exclude it from your serialization

worthy monolith
#

I posted the entire project code. There is no ui, no camera, and in fact no entities.

#

As stated, I have no idea where this atomic is in my stack

magic haven
#

You posted a zip, can you make a repo instead?

worthy monolith
#

I'm pretty certain I did not post a zip

#

The code is contained in the text body of the post

#

I'm working on a minimum reproduction of the error. I'll post that as a repo in a minute

magic haven
worthy monolith
#

Ah ok

magic haven
worthy monolith
#

Windows 11 currently, as that's what I'm using

magic haven
worthy monolith
#

Not yet. I didn't know about that feature. I'll try it

radiant basin
#

disallow the AccessibilityRequested Resource

#

though it'd probably be better to specifically include only the resources and components you definitely want saved

worthy monolith
#

I'm not familiar with that functionality. How would I do that, and where should I look in the docs to learn more?

radiant basin
#

DynamicScene

#

*Builder

magic haven
radiant basin
#

my save system's just settings and a character profile, no reflection
if i actually wanted savestates i'd still use an allowlist manually though

magic haven
#

Yeah but that's far more cumbersome than just <save_these>

radiant basin
#

for instance if you save all the physics components in avian you'll have problems when you load those entities, since it has a desynced state

magic haven
#

So now you're wrangling complex interfaces and weird methods name instead of <ON_SAVE> move data from Res/components to HashMap and serialize it.

radiant basin
#

can do that with a DynamicScene

magic haven
#

Yeah but the issue is when you're loading the dynamic scene into the world.

#

You might want to get bits of the data one by one, in order to make a complete spawn instead of spawning an incomplete DynamicScene

worthy monolith
#

To be honest, I'm probably just going to roll my own save system at this point. Marking as solved, though this solution will require a lot of work.