Skip to content

Commit 56604b6

Browse files
Brooooooklynforehalo
authored andcommitted
fix(native): do not crash on bootstrap if API is not available (#10582)
1 parent 00398fc commit 56604b6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/frontend/native/media_capture/src/macos/screen_capture_kit.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ unsafe impl Encode for NSRect {
7474
const ENCODING: Encoding = Encoding::Struct("NSRect", &[<NSPoint>::ENCODING, <NSSize>::ENCODING]);
7575
}
7676

77-
static RUNNING_APPLICATIONS: LazyLock<RwLock<Vec<AudioObjectID>>> =
78-
LazyLock::new(|| RwLock::new(audio_process_list().expect("Failed to get running applications")));
77+
static RUNNING_APPLICATIONS: LazyLock<
78+
RwLock<std::result::Result<Vec<AudioObjectID>, CoreAudioError>>,
79+
> = LazyLock::new(|| RwLock::new(audio_process_list()));
7980

8081
static APPLICATION_STATE_CHANGED_SUBSCRIBERS: LazyLock<
8182
RwLock<HashMap<AudioObjectID, HashMap<Uuid, Arc<ThreadsafeFunction<(), ()>>>>>,
@@ -551,9 +552,8 @@ impl ShareableContent {
551552
)
552553
})
553554
.and_then(|mut running_applications| {
554-
audio_process_list().map_err(From::from).map(|apps| {
555-
*running_applications = apps;
556-
})
555+
*running_applications = audio_process_list();
556+
Ok(())
557557
})
558558
{
559559
callback.call(Err(err), ThreadsafeFunctionCallMode::NonBlocking);
@@ -673,6 +673,7 @@ impl ShareableContent {
673673
)
674674
})?
675675
.iter()
676+
.flatten()
676677
.filter_map(|id| {
677678
let app = TappableApplication::new(*id);
678679
if !app.bundle_identifier().ok()?.is_empty() {

0 commit comments

Comments
 (0)