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

SceneSpawner::spawn_dynamic doesn't hold the handle after 0.12 #10482

Closed
Shatur opened this issue Nov 9, 2023 · 1 comment · Fixed by #10619
Closed

SceneSpawner::spawn_dynamic doesn't hold the handle after 0.12 #10482

Shatur opened this issue Nov 9, 2023 · 1 comment · Fixed by #10619
Labels
A-Scenes Serialized ECS data stored on the disk C-Bug An unexpected or incorrect behavior
Milestone

Comments

@Shatur
Copy link
Contributor

Shatur commented Nov 9, 2023

Bevy version

0.12

What you did

On 0.11 the following code worked just fine:

let mut scenes = app.world.resource_mut::<Assets<DynamicScene>>();
let scene_handle = scenes.add(dynamic_scene);
let mut scene_spawner = app.world.resource_mut::<SceneSpawner>();
scene_spawner.spawn_dynamic(scene_handle);

But after 0.12 the code fails to spawn the scene. It's because I need to call .clone() on scene_handle, otherwise the handle will be dropped. I would expect scene spawner to hold the handle when I call spawn_dynamic.

@Shatur Shatur added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Nov 9, 2023
Shatur added a commit to Bendzae/bevy_replicon_fork that referenced this issue Nov 9, 2023
It's an odd behavior, already reported:
bevyengine/bevy#10482
@alice-i-cecile alice-i-cecile added A-Scenes Serialized ECS data stored on the disk and removed S-Needs-Triage This issue needs to be labelled labels Nov 9, 2023
@alice-i-cecile alice-i-cecile added this to the 0.12.1 milestone Nov 9, 2023
@cart
Copy link
Member

cart commented Nov 16, 2023

Hmmm yeah we moved to AssetId (effectively a weak handle) across the board for SceneSpawner in Bevy Asset V2, the idea being that we shouldn't be keeping scene assets alive for already spawned scenes. Although I do think it makes sense to use strong handles for scenes queued to be spawned. So we should "unmigrate" the "queuing" portion of this api.

We haven't hit this issue for things like SceneBundle because it holds the strong handle.

github-merge-queue bot pushed a commit that referenced this issue Nov 18, 2023
# Objective

Fixes #10482

## Solution

Store Handles instead of AssetIds for queued Scenes and DynamicScenes in
SceneSpawner.
cart added a commit that referenced this issue Nov 30, 2023
Fixes #10482

Store Handles instead of AssetIds for queued Scenes and DynamicScenes in
SceneSpawner.
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this issue Jan 9, 2024
# Objective

Fixes bevyengine#10482

## Solution

Store Handles instead of AssetIds for queued Scenes and DynamicScenes in
SceneSpawner.
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants