Skip to content

Commit 9d122a7

Browse files
silvestrpredkomockersf
authored andcommitted
Run handle_lifetime only when AudioSink is added to the world (#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 4aca402 commit 9d122a7

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
@@ -37,7 +37,16 @@ fn main() {
3737
// This can help reduce cpu usage on mobile devices
3838
.insert_resource(WinitSettings::mobile())
3939
.add_systems(Startup, (setup_scene, setup_music))
40-
.add_systems(Update, (touch_camera, button_handler, handle_lifetime))
40+
.add_systems(
41+
Update,
42+
(
43+
touch_camera,
44+
button_handler,
45+
// Only run the lifetime handler when an [`AudioSink`] component exists in the world.
46+
// This ensures we don't try to manage audio that hasn't been initialized yet.
47+
handle_lifetime.run_if(any_with_component::<AudioSink>),
48+
),
49+
)
4150
.run();
4251
}
4352

0 commit comments

Comments
 (0)