-
Notifications
You must be signed in to change notification settings - Fork 26
Description
BaseLib has several compatibility issues when running on Android devices that cause crashes during mod initialization and gameplay with custom characters.
Environment
- Game: Slay the Spire 2 v0.98.0
- BaseLib Version: v0.0.4
- Platform: Android (Pixel 5, ARM64)
- Android Version: Android 14
- .NET Runtime: .NET 9.0.7
Issues Found
Issue 1: Config File Path Access Denied
Description: ModConfig uses Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) which returns an empty string on Android, falling back to Environment.SpecialFolder.Personal which resolves to /data/.baselib. This path is not writable by the app, causing UnauthorizedAccessException.
Error Log:
[ERROR] [BaseLib] Failed to save config BaseLibConfig;
[ERROR] [BaseLib] System.UnauthorizedAccessException: Access to the path '/data/.baselib' is denied.
---> System.IO.IOException: Permission denied
Location: Config/ModConfig.cs, lines 41-44
Suggested Fix:
string appData;
if (OperatingSystem.IsAndroid())
{
// On Android, use Godot's user data directory
appData = Godot.OS.GetUserDataDir();
}
else
{
appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
if (appData == "") appData = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
}Issue 2: Harmony Patch Failures Due to IL Differences
Description: Several Harmony patches fail on Android because the compiled IL code differs from the Windows version. The InstructionMatcher uses hardcoded local variable indices (e.g., stloc.s(24)) that don't match on Android.
Affected Patches:
TheBigPatchToCardPileCmdAdd- Fails to find IL pattern matchPersistPatch-GetResultPileType()patch failsGetNCardPile-FindOnTable()patch failsGetPilePosition-GetTargetPosition()patch fails
Error Log:
[ERROR] Exception thrown when calling mod initializer of type BaseLib.MainFile
---> System.Exception: Failed to find match:
InstructionMatcher:
stloc.s 24
ldloc.s 24
ldc.i4.1 NULL
sub NULL
switch NULL
Suggested Fix:
- Wrap
harmony.PatchAll()and individual patch calls in try-catch blocks - Use more flexible IL pattern matching that doesn't rely on specific local variable indices
- Add fallback behavior when patches fail
Issue 3: ProgressSaveManager Patch Signature Mismatch
Description: Mods that depend on BaseLib (like LexNinjaPort) cannot patch ProgressSaveManager.UpdateAfterCombatWon on Android because the method internally references FightStats.set_Character(ModelId) which doesn't exist on Android, causing Harmony to fail during patch application.
Error Log:
[ERROR] HarmonyException: Patching exception in method System.Void MegaCrit.Sts2.Core.Saves.Managers.ProgressSaveManager::UpdateAfterCombatWon(...)
---> System.MissingMethodException: Method not found: void MegaCrit.Sts2.Core.Saves.FightStats.set_Character(MegaCrit.Sts2.Core.Models.ModelId)
Impact: Custom characters freeze the game after winning elite/boss fights because UpdateAfterCombatWon throws ArgumentOutOfRangeException for unknown characters, and the exception cannot be suppressed via Harmony patches.
Steps to Reproduce
- Install BaseLib v0.0.4 on Android
- Launch Slay the Spire 2
- Observe crash during mod initialization (Issue 1 & 2)
- With workarounds applied, select a custom character mod
- Win an elite or boss fight
- Game freezes (Issue 3)
Expected Behavior
BaseLib should initialize successfully on Android and allow custom character mods to function properly.
Actual Behavior
- Game crashes during BaseLib initialization due to file access issues
- Multiple Harmony patches fail silently or with errors
- Custom characters cause game freeze after combat wins
Workarounds Applied (for testing)
- Skip
ModConfigRegistry.Registeron Android - Use
ApplyPatchesSafely()method to individually try-catch each patch class - Use
Godot.OS.GetUserDataDir()for config file path on Android
Suggested Solution
Consider adding Android-specific handling in BaseLib:
- Config path: Use
Godot.OS.GetUserDataDir()on Android - Patch resilience: Wrap all patch operations in try-catch with logging
- Documentation: Document known Android limitations for mod developers
- Optional patches: Allow mods to gracefully degrade when certain patches fail
Related
- Affects any mod using custom characters via
PlaceholderCharacterModel - Tested with LexNinjaPort mod
Additional Context
Android uses a different .NET runtime configuration and the game's IL code may be compiled differently, causing pattern-based Harmony patches to fail. The workarounds described above allow BaseLib to load successfully, but the ProgressSaveManager issue remains unsolved without changes to the patching approach.