Skip to content

Commit 4d1569e

Browse files
committed
[macos] Kill autofill process not closed by macOS
1 parent 96b1bd2 commit 4d1569e

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

platforms/desktop-shared/application.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ static void* macos_fullscreen_observer = NULL;
8787
static void* macos_nswindow = NULL;
8888
extern "C" void* macos_install_fullscreen_observer(void* nswindow, void(*enter_cb)(), void(*exit_cb)());
8989
extern "C" void macos_set_native_fullscreen(void* nswindow, bool enter);
90+
extern "C" void macos_kill_autofill_helpers(const char* app_name);
9091
#endif
9192

9293
int application_init(const char* rom_file, const char* symbol_file, bool force_fullscreen, bool force_windowed)
@@ -174,6 +175,10 @@ void application_destroy(void)
174175
ImGui_ImplSDL2_Shutdown();
175176
gui_destroy();
176177
sdl_destroy();
178+
179+
#if defined(__APPLE__)
180+
macos_kill_autofill_helpers(GEARBOY_TITLE);
181+
#endif
177182
}
178183

179184
void application_mainloop(void)

platforms/macos/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include ../desktop-shared/Makefile.sources
22

33
SOURCES_MM += $(DESKTOP_SRC_DIR)/nfd/nfd_cocoa.mm
4-
SOURCES_MM += $(DESKTOP_SRC_DIR)/macos/fullscreen.mm
4+
SOURCES_MM += macos.mm
55
OBJECTS += $(SOURCES_MM:.mm=.o)
66
LDFLAGS += -framework AppKit -framework UniformTypeIdentifiers
77

platforms/desktop-shared/macos/fullscreen.mm renamed to platforms/macos/macos.mm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,20 @@ - (void)dealloc
8888
[win toggleFullScreen:nil];
8989
}
9090
}
91+
92+
// Workaround for macOS Tahoe bug: AutoFill helper processes are not terminated on app exit
93+
extern "C" void macos_kill_autofill_helpers(const char* app_name)
94+
{
95+
@autoreleasepool {
96+
NSString* appNameLower = [[NSString stringWithUTF8String:app_name] lowercaseString];
97+
98+
for (NSRunningApplication *app in [[NSWorkspace sharedWorkspace] runningApplications]) {
99+
if ([app.bundleIdentifier isEqualToString:@"com.apple.SafariPlatformSupport.Helper"]) {
100+
NSString* localizedNameLower = [[app localizedName] lowercaseString];
101+
if ([localizedNameLower hasPrefix:@"autofill"] && [localizedNameLower containsString:appNameLower]) {
102+
[app forceTerminate];
103+
}
104+
}
105+
}
106+
}
107+
}

0 commit comments

Comments
 (0)