From 71ce8bb6f00f4d1cbc1012270d6daefdbda4254d Mon Sep 17 00:00:00 2001 From: JosJuice Date: Wed, 16 Aug 2023 21:16:41 +0200 Subject: Don't call RunAsCPUThread in config callbacks In theory, our config system supports calling Set from any thread. But because we have config callbacks that call RunAsCPUThread, it's a lot more restricted in practice. Calling Set from any thread other than the host thread or the CPU thread is formally thread unsafe, and calling Set on the host thread while the CPU thread is showing a panic alert causes a deadlock. This is especially a problem because 04072f0 made the "Ignore for this session" button in panic alerts call Set. Because so many of our config callbacks want their code to run on the CPU thread, I thought it would make sense to have a centralized way to move execution to the CPU thread for config callbacks. To solve the deadlock problem, this new way is non-blocking. This means that threads other than the CPU thread might continue executing before the CPU thread is informed of the new config, but I don't think there's any problem with that. Intends to fix https://bugs.dolphin-emu.org/issues/13108. --- Source/Core/Common/Config/Config.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Config/Config.h b/Source/Core/Common/Config/Config.h index b448f234f9..4d770ee36e 100644 --- a/Source/Core/Common/Config/Config.h +++ b/Source/Core/Common/Config/Config.h @@ -22,7 +22,8 @@ void AddLayer(std::unique_ptr loader); std::shared_ptr GetLayer(LayerType layer); void RemoveLayer(LayerType layer); -// returns an ID that can be passed to RemoveConfigChangedCallback() +// Returns an ID that can be passed to RemoveConfigChangedCallback(). +// The callback may be called from any thread. size_t AddConfigChangedCallback(ConfigChangedCallback func); void RemoveConfigChangedCallback(size_t callback_id); void OnConfigChanged(); -- cgit v1.2.3