Investigate 64-bit support
Pathoschild opened this issue ยท 15 comments
Some players have been getting frequent OutOfMemoryException
issues in recent months, largely due to the game's 32-bit memory limitations. Look into what would be needed to support a 64-bit version of Stardew Valley, either as changes to propose to the game devs or in an unofficial port.
To do
- Figure out how to make Stardew Valley 64-bit.
- Create patcher/installer to simplify making the game 64-bit.
- Make SMAPI compatible with 64-bit game.
- Draft migration guide for mod authors.
- Test & iterate to iron out issues and simplify the process.
- Figure out release process.
- Update open-source mods for 64-bit compatibility where needed.
Known issues
This section lists known issues that need to be addressed before release. Solved items are removed from the list.
- All known game/SMAPI issues resolved!
- Most affected mods are now updated for 64-bit. Some remaining mods may be updated (officially or unofficially) after release.
Special thanks to @Dradonhunter11, who figured out how to run a 64-bit version of Stardew Valley on Windows! I documented the steps below (updated 2021-03-17).
Caveats: these are preliminary notes for developers, they're not meant for players. SMAPI also won't work with this approach yet, since it assumes XNA Framework on Windows.
Expand for setup guide
- Download the Linux version of the game on Windows (since we need MonoGame instead of XNA):
- Open the Steam command console (URL:
steam://nav/console
, requires Steam). - Run this command to download the latest Linux version:
download_depot 413150 413153
- Wait for Steam to finish downloading it. This may take a while and it won't show any download progress, but you'll see network usage on the downloads tab. Eventually the console will show "Depot download complete", followed by the path where it downloaded the files.
- "Game folder" in the instructions below refers to this new folder, not your actual installed game folder.
- Open the Steam command console (URL:
- Add these files to the game folder:
- Edit
StardewValley.exe
in dnSpy to make these changes:- Reorder this code in
Game1.Initialize
:And add the// old order Game1.audioEngine = new AudioEngineWrapper(new AudioEngine(Path.Combine(rootpath, "XACT", "FarmerSounds.xgs"))); Game1.waveBank = new WaveBank(Game1.audioEngine.Engine, Path.Combine(rootpath, "XACT", "Wave Bank.xwb")); Game1.waveBank1_4 = new WaveBank(Game1.audioEngine.Engine, Path.Combine(rootpath, "XACT", "Wave Bank(1.4).xwb")); Game1.soundBank = new SoundBankWrapper(new SoundBank(Game1.audioEngine.Engine, Path.Combine(rootpath, "XACT", "Sound Bank.xsb"))); // new order Game1.audioEngine = new AudioEngineWrapper(new AudioEngine(Path.Combine(rootpath, "XACT", "FarmerSounds.xgs"))); Game1.soundBank = new SoundBankWrapper(new SoundBank(Game1.audioEngine.Engine, Path.Combine(rootpath, "XACT", "Sound Bank.xsb"))); Game1.waveBank = new WaveBank(Game1.audioEngine.Engine, Path.Combine(rootpath, "XACT", "Wave Bank.xwb")); Game1.waveBank1_4 = new WaveBank(Game1.audioEngine.Engine, Path.Combine(rootpath, "XACT", "Wave Bank(1.4).xwb"));
if
checks in thecatch
:catch (Exception e) { Console.WriteLine("Game.Initialize() caught exception initializing XACT:\n{0}", e); if (Game1.audioEngine == null) Game1.audioEngine = new DummyAudioEngine(); if (Game1.soundBank == null) Game1.soundBank = new DummySoundBank(); }
- Edit the
KeyboardDispatcher
constructor, and change this code:To this:if (Environment.OSVersion.Platform == PlatformID.Unix) { window.TextInput += Event_TextInput; return; } if (Game1.game1.IsMainInstance) KeyboardInput.Initialize(window); KeyboardInput.CharEntered += EventInput_CharEntered; KeyboardInput.KeyDown += EventInput_KeyDown;
window.TextInput += Event_TextInput; // TODO: not sure if the code below is needed if (Game1.game1.IsMainInstance) KeyboardInput.Initialize(window);
- Reorder this code in
- Run this command in the game folder using CorFlags:
CorFlags.exe StardewValley.exe /REQ32BIT-
- Finally, run the game and it should be 64-bit. (On Windows, you can confirm by opening the task manager and confirming the app's process doesn't have
(32 bit)
next to it.)
Thanks to @steviegt6, we now have an installer that makes Stardew Valley 64-bit too!
It's not ready for players to use (we'll need to document the process and SMAPI itself won't work with it yet), but we're getting closer to a working alpha.
Thanks to @steviegt6, we now have an installer that makes Stardew Valley 64-bit too!
It's not ready for players to use (we'll need to document the process and SMAPI itself won't work with it yet), but we're getting closer to a working alpha.
Hey, thanks for the mention!
Still finishing some stuff up, but I've gotten far enough to copy over DLLs and use MonoMod to create a patched EXE. Still ironing out some issues, though. It should be ready in the next few hours. (See edit)
EDIT: Gotten the set-up process to work, however having some issues with MonoMod. Currently, no ETA on when it'll be ready, but hopefully later today or later tomorrow.
EDIT 2: Officially released 1.0.0 of the installer (see message below).
v1.0.0 of the installer has been officially released: https://github.com/Steviegt6/Stardew64Installer/releases/tag/1.0.0
@Pathoschild Apparently corflags need to be ran on the exe too, as the linux version come as an x86 assembly, also the documentation from microsoft is wrong regarding corflags, the right one is /REQ32BIT-
v1.0.1 fixes CorFlags issues and comes with steamapi_64.dll and a fixed Steamworks.NET.dll. https://github.com/Steviegt6/Stardew64Installer/releases/tag/1.0.1
SMAPI is experimentally compatible with the 64-bit hack in the mod/64-bit-support
branch, though there's a few in-game issues to look into.
Here's the updated process with @steviegt6's patcher and SMAPI's 64-bit support. These are preliminary notes for developers, they're not meant for players.
Expand for setup guide
- Download the Linux version of the game on Windows (since we need MonoGame instead of XNA):
- Open the Steam command console (URL:
steam://nav/console
, requires Steam). - Run this command to download the latest Linux version:
download_depot 413150 413153
- Wait for Steam to finish downloading it. This may take a while and it won't show any download progress, but you'll see network usage on the downloads tab. Eventually the console will show "Depot download complete", followed by the path where it downloaded the files.
- Open the Steam command console (URL:
- Run the patcher tool:
- Download and unzip the latest Stardew64Installer release.
- Double-click the
SDV.Installer.exe
file. - When it asks, paste the full path to the Linux version from step 1-iii above and hit enter.
- If all goes well, it should show "Installation complete!" after a short while.
- Compile and install 64-bit SMAPI:
- Clone the SMAPI repo.
- Switch to the
mod/64-bit-support
branch. - Edit
build/common.targets
file and uncomment this line:<DefineConstants>$(DefineConstants);SMAPI_FOR_WINDOWS_64BIT_HACK</DefineConstants>
- Click Build > Rebuild Solution.
- Find the compiled installer in
bin/SMAPI installer
. - Manually install it into the game folder (see its
README.txt
for instructions).
- Finally, run
StardewModdingAPI.exe
in the game folder and it should be 64-bit. (You can check by opening the task manager and confirming the app's process doesn't have(32 bit)
next to it.)
We now have a draft migration guide for mod authors, which documents changes they might need to make for compatibility with 64-bit.
A 64-bit SMAPI alpha is now available! See the pinned message in #making-mods on Discord for the latest info.
Progress is happening! It's less laggy than it one was, but there is still some there and the screen tearing remains. Here's another log full of errors, I made sure everything was updated.
https://smapi.io/log/3e9f362e1b6a4fce9fbbd98f47e240a0
@Dichotomy754 Thanks! That's due to some of your mods being broken in 64-bit, so it should improve as we continue to update affected mods. I'll submit PRs for some of the affected mods in your log.
Update: 64-bit is almost fully functional at this point. The main issues left are (a) an error when initializing the GOG or Steam SDK, (b) an error when taking an in-game screenshot, and (c) a few mods which aren't 64-bit-ready yet. I added a Known issues section to the description above with more details.
Done in the upcoming SMAPI 3.10. See Migrate to 64-bit on Windows for more info.