Skip to content

Commit 082d871

Browse files
Run handle_lifetime only when AudioSink is added to the world (bevyengine#17637)
# Objective Fixes: https://discord.com/channels/691052431525675048/756998293665349712/1335019849516056586 ## Solution Let's wait till `AudioSInk` will be added to the world. ## Testing Run ios example
1 parent e57f732 commit 082d871

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

examples/mobile/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@ fn main() {
4141
// This can help reduce cpu usage on mobile devices
4242
.insert_resource(WinitSettings::mobile())
4343
.add_systems(Startup, (setup_scene, setup_music))
44-
.add_systems(Update, (touch_camera, button_handler, handle_lifetime))
44+
.add_systems(
45+
Update,
46+
(
47+
touch_camera,
48+
button_handler,
49+
// Only run the lifetime handler when an [`AudioSink`] component exists in the world.
50+
// This ensures we don't try to manage audio that hasn't been initialized yet.
51+
handle_lifetime.run_if(any_with_component::<AudioSink>),
52+
),
53+
)
4554
.run();
4655
}
4756

0 commit comments

Comments
 (0)