Skip to content

Commit

Permalink
Run handle_lifetime only when AudioSink is added to the world (#17637)
Browse files Browse the repository at this point in the history
# 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
  • Loading branch information
silvestrpredko authored Feb 2, 2025
1 parent e57f732 commit 082d871
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion examples/mobile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ fn main() {
// This can help reduce cpu usage on mobile devices
.insert_resource(WinitSettings::mobile())
.add_systems(Startup, (setup_scene, setup_music))
.add_systems(Update, (touch_camera, button_handler, handle_lifetime))
.add_systems(
Update,
(
touch_camera,
button_handler,
// Only run the lifetime handler when an [`AudioSink`] component exists in the world.
// This ensures we don't try to manage audio that hasn't been initialized yet.
handle_lifetime.run_if(any_with_component::<AudioSink>),
),
)
.run();
}

Expand Down

0 comments on commit 082d871

Please sign in to comment.