Launch issue on M1 (ARM) versions of MacOS
econoboxed opened this issue ยท 12 comments
Description
SMAPI 3.12.2 functions correctly after a fresh install on M1 macs, but hangs on subsequent game launches. This is not the behaviour on X86 versions of MacOS, nor was it the behaviour with SMAPI 3.11.0 on ARM Macs.
To Reproduce
Install SMAPI 3.12.2 on an ARM-based Mac with these mods in the mods folder
Wait for the game to successfully launch to the title screen, and quit Stardew Valley.
Re-launch the game, the launcher should now hang.
Log files
Log file of SMAPI 3.12.2 successfully launching on an M1 mac after a fresh install
Log file of the same SMAPI / Mod installation, hanging on the second launch
Log file of SMAPI 3.12.2 and the same mods consistently launching correctly on an X86-based Mac
Log file of SMAPI 3.11.0 launching on the same M1 mac using these slightly older versions of the same mods
Other notes
Upon googling this issue is mentioned in this Stardew Valley forums thread, and a similar issue is mentioned in this Reddit thread, though those users did not specify whether they were running SMAPI on M1 macs.
This is my first bug report, so apologies if I missed a rule while posting. Let me know if I can provide any further information, I'd be happy to help.
Tried the beta, installed .net, game launched just fine the first time. Now it's no longer launching, giving me a bunch of red errors.
[SMAPI] Starting game...
[game] The game failed to launch: System.NullReferenceException: Object reference not set to an instance of an object.
at StardewValley.LocalizedContentManager.LanguageCodeString(LanguageCode code)
at StardewModdingAPI.Framework.ContentManagers.BaseContentManager.GetKeyLocales() in /home/pathoschild/Desktop/SMAPI/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs:line 319
at StardewModdingAPI.Framework.ContentManagers.BaseContentManager..ctor(String name, IServiceProvider serviceProvider, String rootDirectory, CultureInfo currentCulture, ContentCoordinator coordinator, IMonitor monitor, Reflector reflection, Action1 onDisposing, Boolean isNamespaced, Boolean aggressiveMemoryOptimizations) in /home/pathoschild/Desktop/SMAPI/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs:line 95 at StardewModdingAPI.Framework.ContentCoordinator..ctor(IServiceProvider serviceProvider, String rootDirectory, CultureInfo currentCulture, IMonitor monitor, Reflector reflection, JsonHelper jsonHelper, Action onLoadingFirstAsset, Boolean aggressiveMemoryOptimizations) in /home/pathoschild/Desktop/SMAPI/src/SMAPI/Framework/ContentCoordinator.cs:line 107 at StardewModdingAPI.Framework.SCore.CreateContentManager(IServiceProvider serviceProvider, String rootDirectory) in /home/pathoschild/Desktop/SMAPI/src/SMAPI/Framework/SCore.cs:line 1134 at StardewValley.Game1..ctor() at StardewModdingAPI.Framework.SGame..ctor(PlayerIndex playerIndex, Int32 instanceIndex, Monitor monitor, Reflector reflection, EventManager eventManager, SInputState input, SModHooks modHooks, SMultiplayer multiplayer, Action
1 exitGameImmediately, Action`3 onUpdating) in /home/pathoschild/Desktop/SMAPI/src/SMAPI/Framework/SGame.cs:line 110
at StardewModdingAPI.Framework.SGameRunner.CreateGameInstance(PlayerIndex playerIndex, Int32 instanceIndex) in /home/pathoschild/Desktop/SMAPI/src/SMAPI/Framework/SGameRunner.cs:line 97
at StardewValley.GameRunner.AddGameInstance(PlayerIndex player_index)
at StardewModdingAPI.Framework.SGameRunner.AddGameInstance(PlayerIndex playerIndex) in /home/pathoschild/Desktop/SMAPI/src/SMAPI/Framework/SGameRunner.cs:line 103
at StardewValley.GameRunner.Initialize()
at Microsoft.Xna.Framework.Game.DoInitialize()
at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
at StardewModdingAPI.Framework.SCore.RunInteractively() in /home/pathoschild/Desktop/SMAPI/src/SMAPI/Framework/SCore.cs:line 289
[SMAPI] Game has ended. Press any key to exit.
An update to the game was released last night that broke SMAPI. Wait until SMAPI is updated or downgrade your game.
@jimbo1111 SMAPI updated shortly after the game; install the latest SMAPI 3.13.0 beta to fix that.
Temporary solution would be to run terminal as an x86 application through Rosetta2. Essentially right click on terminal - get info - run through rosetta(?). When you run the game (at least through the steam .exe(equivalent for Mac) it works. Of course the game runs through translated code and is therefore not as efficient as normal m1 performance, but it works.
Temporary solution would be to run terminal as an x86 application through Rosetta2. Essentially right click on terminal - get info - run through rosetta(?). When you run the game (at least through the steam .exe(equivalent for Mac) it works. Of course the game runs through translated code and is therefore not as efficient as normal m1 performance, but it works.
This does not work for me
This is an issue for me on my M1 Mac as well. I'm on macOS 12, reinstalling occasionally will let it boot. This is very apparent with Stardew Valley Expanded, where the chances of the game launching are diminished.
Temporary solution would be to run terminal as an x86 application through Rosetta2. Essentially right click on terminal - get info - run through rosetta(?). When you run the game (at least through the steam .exe(equivalent for Mac) it works. Of course the game runs through translated code and is therefore not as efficient as normal m1 performance, but it works.
This is incorrect and will not work. When you install mono, the only prebuilt binaries are already in x86_64 so Rosetta will be used by default, regardless of launch method. You can build yourself mono for aarch64, which I have done. Using my own build of mono I was able to launch the vanilla game on native Apple Silicon, which is not possible through the Steam download because Steam packages a stripped down mono runtime for x86_64.
Because I am able to launch the vanilla game through my own build of ARM mono, all we need are ARM binaries of SMAPI. The installer only has the x86_64 dll files, but if ARM binaries were built I believe many of the issues that people have been experiencing on the Mac like this startup issue and the multiplayer disconnect would be fixed.
The Stardew Valley 1.5.5 beta modernizes the underlying frameworks (in particular replacing Mono with .NET 5). Do you have the same issues if you try the beta version?
I will give it a shot, but the underlying problem of not having a native ARM build will remain by switching to .NET as it's only distributed in binaries from what I can see.
With .NET 5 we just have a StardewModdingAPI.dll
which gets run through the dotnet
process. I'm hoping that lets us avoid needing separate ARM builds of SMAPI.
The Stardew Valley 1.5.5 beta modernizes the underlying frameworks (in particular replacing Mono with .NET 5). Do you have the same issues if you try the beta version?
Just tried the beta and did not encounter the issue - I was able to close and reopen Stardew several times without a hang.
Let me know if you need any other details, and thanks for looking into this.
This seems to be fixed by either running SMAPI 3.12.x through Rosetta or updating to SMAPI 3.13.0 beta, so I'll close this ticket. Thanks for reporting it!