diff --git a/DXMainClient/DXGUI/GameClass.cs b/DXMainClient/DXGUI/GameClass.cs index 89494a925..37f2f3db5 100644 --- a/DXMainClient/DXGUI/GameClass.cs +++ b/DXMainClient/DXGUI/GameClass.cs @@ -22,7 +22,6 @@ using DTAClient.Online; using ClientGUI.Settings; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; using Rampastring.XNAUI.XNAControls; using MainMenu = DTAClient.DXGUI.Generic.MainMenu; using System.Threading.Tasks; @@ -259,9 +258,12 @@ private static Random GetRandom() private IServiceProvider BuildServiceProvider(WindowManager windowManager) { - // Create host - this allows for things like DependencyInjection - IHost host = Host.CreateDefaultBuilder() - .ConfigureServices((_, services) => + // Dependency-injection container. This previously built a full .NET Generic Host + // (Host.CreateDefaultBuilder().Build()), but the client only ever used it as a DI + // container, and that Build() hangs on macOS: the host's configuration provider sets + // up a FileSystemWatcher (reloadOnChange), whose FSEvents-backed setup stalls there. + // A plain ServiceCollection provides the same DI with none of that machinery. + var services = new ServiceCollection(); { // services (or service-like) services @@ -336,10 +338,8 @@ private IServiceProvider BuildServiceProvider(WindowManager windowManager) .AddTransientXnaControl() .AddTransientXnaControl(); } - ) - .Build(); - return host.Services.GetService(); + return services.BuildServiceProvider(); } private void InitializeUISettings() diff --git a/DXMainClient/Domain/Multiplayer/MapLoader.cs b/DXMainClient/Domain/Multiplayer/MapLoader.cs index 81fb18c83..031d8a95e 100644 --- a/DXMainClient/Domain/Multiplayer/MapLoader.cs +++ b/DXMainClient/Domain/Multiplayer/MapLoader.cs @@ -114,7 +114,12 @@ public MapLoader() { } public void Initialize() { - MapLoadingComplete += (sender, args) => StartMapFileWatcher(); + // .NET's FileSystemWatcher (FSEvents-backed) stalls during setup on macOS. + // Since MapLoadingComplete is invoked synchronously, that would block the map + // loading task from ever completing and hang the client on the loading screen. + // Skip the live map-file watcher on macOS; maps still load, just no hot-reload. + if (!OperatingSystem.IsMacOS()) + MapLoadingComplete += (sender, args) => StartMapFileWatcher(); } ///