Skip to content

Commit 710ffe8

Browse files
author
Robert Venturini
committed
legacyScreenSaver process exits
Hack to side step the legacyScreenSaver bug that was introduced in macOS 14. Each time a legacy screensave runs, the process fails to terminate and leaks potentially large amounts of memory.
1 parent 2abe4c5 commit 710ffe8

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Flying Toasters/FlyingToasterScreenSaverView.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#import "FlyingToastersView.h"
1111
#import "FlyingToasterScreenSaverView.h"
1212

13+
static NSNotificationName const ScreenSaverWillStopNotificationName = @"com.apple.screensaver.willstop";
14+
1315
@interface FlyingToasterScreenSaverView ()
1416
@property (strong) FlyingToastersView* ftv;
1517
@property (strong) FlyingToasterPreferencesController* prefsController;
@@ -25,6 +27,12 @@ - (instancetype)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview
2527
_ftv.frame = NSMakeRect(0, 0, frame.size.width, frame.size.height);
2628

2729
[self addSubview:_ftv];
30+
31+
32+
[[NSDistributedNotificationCenter defaultCenter] addObserver:self
33+
selector:@selector(screenSaverWillStopNotification:)
34+
name:ScreenSaverWillStopNotificationName
35+
object:nil];
2836
}
2937

3038
return self;
@@ -71,4 +79,16 @@ - (NSWindow*)configureSheet
7179
return _prefsController.window;
7280
}
7381

82+
- (void)screenSaverWillStopNotification:(NSNotification*)notification
83+
{
84+
if (@available(macOS 14.0, *)) {
85+
// Bug in macOS 14+ warrants forcefully exiting the screensaver
86+
// so that the 'legacyScreenSaver' process will also quit and release its memory.
87+
// This is hacky, but seems to side step the problem.
88+
// This approach was reported working on the aerial screensaver here:
89+
// https://github.com/JohnCoates/Aerial/issues/1305
90+
exit(0);
91+
}
92+
}
93+
7494
@end

Flying Toasters/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>BNDL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0</string>
18+
<string>1.2</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

0 commit comments

Comments
 (0)