Skip to content

Commit cd386a3

Browse files
committed
[GameMode] Don't probe libgamemode on every config load, preserve user setting
Two related fixes for the GameMode startup behavior on Linux: 1. configuration.c: Only call frontend_driver_set_gamemode() during config load when gamemode_enable is actually true. Previously the probe ran unconditionally with the current setting value, meaning every user on every config load triggered a dlopen of libgamemode.so even when the feature was off - producing log spam ("[GameMode] GameMode cannot be enabled on this system...") for the majority of users who don't have libgamemode installed. Also stop force-disabling gamemode_enable in the config when the probe fails. Silently flipping the user's preference to false and persisting it to retroarch.cfg meant a transient failure (sandbox path issue, library not yet installed, multi-arch mismatch, etc.) would require the user to manually re-enable the option on every subsequent launch. The user's intent should survive across sessions; if libgamemode shows up later, the next launch picks it up automatically. 2. frontend/drivers/platform_unix.c: Latch the unavailable state inside frontend_unix_set_gamemode() once gamemode_query_status() reports failure. The result will not change for the lifetime of the process, so subsequent calls (deinit cleanup, menu toggles) short-circuit without re-entering the Feral client code and without re-emitting the warning. The warning now fires exactly once per process when the user has gamemode enabled but libgamemode is missing. The redundant "[Config] GameMode unsupported - disabling..." follow-up warning is removed - it added no information beyond what the GameMode warning already conveys.
1 parent 0a77580 commit cd386a3

2 files changed

Lines changed: 25 additions & 10 deletions

File tree

configuration.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4653,14 +4653,16 @@ static bool config_load_file(global_t *global,
46534653
if (!(bool)RHMAP_HAS_STR(conf->entries_map, "user_language"))
46544654
msg_hash_set_uint(MSG_HASH_USER_LANGUAGE, frontend_driver_get_user_language());
46554655

4656-
if (frontend_driver_has_gamemode() &&
4657-
!frontend_driver_set_gamemode(settings->bools.gamemode_enable) &&
4658-
settings->bools.gamemode_enable)
4659-
{
4660-
RARCH_WARN("[Config] GameMode unsupported - disabling...\n");
4661-
configuration_set_bool(settings,
4662-
settings->bools.gamemode_enable, false);
4663-
}
4656+
/* If GameMode is enabled in the config but libgamemode is not
4657+
* available, warn once. Do NOT clear the setting: that would
4658+
* silently overwrite the user's preference in retroarch.cfg, so
4659+
* a transient failure (sandbox path issue, library not yet
4660+
* installed, etc.) would force them to re-enable it manually on
4661+
* every subsequent launch. The probe is latched inside the
4662+
* frontend driver, so it will not be retried this session. */
4663+
if ( settings->bools.gamemode_enable
4664+
&& frontend_driver_has_gamemode())
4665+
frontend_driver_set_gamemode(true);
46644666

46654667
/* If this is the first run of an existing installation
46664668
* after the independent favourites playlist size limit was

frontend/drivers/platform_unix.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,8 +2186,20 @@ static void android_app_destroy(struct android_app *android_app)
21862186
static bool frontend_unix_set_gamemode(bool on)
21872187
{
21882188
#ifdef FERAL_GAMEMODE
2189-
int gamemode_status = gamemode_query_status();
2190-
bool gamemode_active = (gamemode_status == 2);
2189+
/* Once gamemode_query_status() reports failure (typically because
2190+
* libgamemode.so is not installed), there is no point repeatedly
2191+
* re-probing on every config load or menu toggle - the result will
2192+
* not change for the lifetime of the process, and each probe emits
2193+
* a warning. Latch the unavailable state and short-circuit. */
2194+
static bool gamemode_unavailable = false;
2195+
int gamemode_status;
2196+
bool gamemode_active;
2197+
2198+
if (gamemode_unavailable)
2199+
return false;
2200+
2201+
gamemode_status = gamemode_query_status();
2202+
gamemode_active = (gamemode_status == 2);
21912203

21922204
if (gamemode_status < 0)
21932205
{
@@ -2196,6 +2208,7 @@ static bool frontend_unix_set_gamemode(bool on)
21962208
"https://github.com/FeralInteractive/gamemode needs to be installed.\n",
21972209
gamemode_error_string());
21982210

2211+
gamemode_unavailable = true;
21992212
return false;
22002213
}
22012214

0 commit comments

Comments
 (0)