Skip to content

Commit 809b925

Browse files
committed
fix: exclude a caller's windows that are not on screen yet
1 parent b1f2671 commit 809b925

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎include/robot/VideoFrame.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ struct VideoFrameInfo {
2525
// padding, resize letterboxing), so this is part of the contract.
2626
LogicalRect contentRect;
2727
// Presentation timestamp mapped onto steady_clock (not delivery time), so
28-
// frame age reflects how old the pixels actually are.
28+
// frame age reflects how old the pixels actually are. macOS can deliver a
29+
// frame before its display time, which makes this a few ms in the future.
2930
std::chrono::steady_clock::time_point capturedAt;
3031
};
3132

‎src/platform/macos/MacWindowBackend.mm‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,15 @@ - (void)streamDidBecomeInactive:(SCStream*)stream {
209209
return value;
210210
}
211211

212-
std::expected<SCShareableContent*, Error> fetchShareableContent() {
212+
std::expected<SCShareableContent*, Error> fetchShareableContent(
213+
const BOOL isOnScreenOnly = YES
214+
) {
213215
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
214216
__block SCShareableContent* content = nil;
215217
__block NSError* error = nil;
216218
[SCShareableContent
217219
getShareableContentExcludingDesktopWindows:YES
218-
onScreenWindowsOnly:YES
220+
onScreenWindowsOnly:isOnScreenOnly
219221
completionHandler:^(
220222
SCShareableContent* result, NSError* err
221223
) {
@@ -538,7 +540,9 @@ void stop() override {
538540
);
539541
}
540542

541-
auto contentResult = fetchShareableContent();
543+
// Includes windows not on screen yet: a caller that creates its overlay just
544+
// before streaming would otherwise not be listed, and so not be excluded.
545+
auto contentResult = fetchShareableContent(NO);
542546
if (!contentResult) return std::unexpected(contentResult.error());
543547

544548
SCDisplay* scDisplay = nil;

0 commit comments

Comments
 (0)