tModLoader / tModLoader

A mod to make and play Terraria mods. Supports Terraria 1.4 (and earlier) installations
https://www.tmodloader.net/
MIT License
4.19k stars 1.88k forks source link

tModLoader Apple M1 #1582

Closed the-real-t30d0r closed 2 years ago

the-real-t30d0r commented 3 years ago

Description

Making tModLoader working properly on Apple M1 (i can contribute as well, very good c# and c++ skills)

What does this proposal attempt to solve or improve?

Making mods working, at the moment not all mods working fine.

Which (other) solutions should be considered?

I have found an workaround for activating mods on m1 (tested on MacOS 12 Monterey Beta and Big Sur 11.4):

  1. Search the mod you want on https://mirror.sgkoi.dev/.
  2. Download it
  3. Copy it to the Mods Library ~/Library/Application Support/Terraria/ModLoader/Mods
  4. Open tModLoader from Steam
  5. Go to Mod
  6. Reload all Mods
  7. Activate the mod by clicking on the "disabled" label (Do not click on "ENABLE ALL")
  8. Restart tModLoader and done. After restarting the mods should work so far.

Remember that not all mods are working so yeah, its kinda experimental

the-real-t30d0r commented 3 years ago

Here, my log file for investigation:

https://paste.mod.gg/izejixabig.cs https://paste.mod.gg/monugofolo.cs

Solxanich commented 3 years ago

Thanks for making this issue! The core work for natively supporting M1 laptops would likely involve migrating to .Net6. FNA & SDL may also require updates. We use Net frameworks to deliver most of the native integration so the task to properly support it wouldn't likely begin until Net6 is available in November. Downloading mods is/will be fixed on 1.4 already

This likely won't be fixed in the 1.3 version of tModLoader - this version is no longer seeing major updates, and is running too old a .Net to make updating it practical.

This should be fixable in 1.4 tModLoader, as that is already on .Net5 so upgrading should be doable. But again, as .Net is a main component on the natives side, until .Net6 comes hands are likely tied.

The workaround for now will have to suffice, and great job identifying that. Feel free to take a look at the code around https://github.com/tModLoader/tModLoader/blob/1.4_mergedtesting/patches/tModLoader/Terraria/ModLoader/UI/UIMods.cs (,or the equivalent file on master) if you're thinking something might be doable.

ProfessorConfundus commented 3 years ago

I have this issue too, I try to download a mod using the mod browser and it won't download. It'll come up with the download bar for a second, but then it'll just disappear and the mod hasn't downloaded.

ngtrio commented 3 years ago

Any progress? I use macbook m1 2020, the game hangs whenever I hover my mouse on the mod items

Solxanich commented 3 years ago

This issue might be resolved on the 1.4 alpha version. If someone wants to confirm its working, it would be appreciated. Assuming its fixed on 1.4, this issue will likely be closed.

Note that 1.3 will likely never be fixed for Apple Silicon/M1 support, or unix in general due to the significant work involved, so this may be closed as fixed in 1.4, won't fix in 1.3.

the-real-t30d0r commented 2 years ago

I can confirm that it runs well on m1 with the 1.4 alpha

Mods browsing works now as well.

Solxanich commented 2 years ago

Perfect, thanks for confirming. I'll leave this open for a week in case someone finds anything not working on M1 on the 1.4 alpha, and if nothing comes up this will be moved to be closed

ProfessorConfundus commented 2 years ago

I can too confirm that mod browsing works perfectly on 1.4 Alpha for M1.

Solxanich commented 2 years ago

Closing with no actions required in 1.4 for M1 basic functionality. 1.3 is legacy only, and will not be updated.

xiongnemo commented 2 years ago

Downloading latest build on M1 then runstart-tModLoader.sh produces following log:

❯ sudo bash start-tModLoader.sh
start-tModLoader.sh: line 6: PPID: readonly variable
You are on platform: "Darwin"
Verifying .NET....
This may take a few moments.
Logging to /Users/nemo/Applications/tModLoader/tModLoader-Logs/Launch.log
Fixing .NET SDL PATH issues
Success!
Verifying .NET platform specific libraries are correctly deployed
Success!
Parsing .NET version requirements from runtimeconfig.json
Success!
Checking for old .NET versions to remove from folder
Cleanup Complete
Checking dotnet install...
Dotnet should be present in "/Users/nemo/Applications/tModLoader/dotnet/6.0.0"
Attempting Launch...
sed: /proc/52065/cmdline: No such file or directory
Launched Using Local Dotnet
[16:47:13] [Main Thread/INFO] [tML]: Save Are Located At: /Users/nemo/Library/Application Support/Terraria/tModLoader
[16:47:13] [Main Thread/INFO] [tML]: Starting tModLoader client 1.4.3.6+2022.05.103.34|1.4-stable|Stable|3e55752ca78debad58596ddaafbffb3b744e0470|5249600284767593499 built 2022/6/22 00:43
[16:47:13] [Main Thread/INFO] [tML]: Log date: 2022/6/27
[16:47:13] [Main Thread/INFO] [tML]: Running on OSX Arm64 NetCore 6.0.0
[16:47:13] [Main Thread/INFO] [tML]: Executable: /Users/nemo/Applications/tModLoader/tModLoader.dll
[16:47:13] [Main Thread/INFO] [tML]: Working Directory: /Users/nemo/Applications/tModLoader
Operation is not supported on this platform. tModLoader.RuntimeErrorSeeLogsForFullTrace
[16:47:14] [Main Thread/WARN] [tML]: tModLoader.RuntimeErrorSilentlyCaughtException
System.PlatformNotSupportedException: Operation is not supported on this platform.
   at MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETCorePlatform.GetJitObject()
   at MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETCorePlatform.Create()
   at MonoMod.RuntimeDetour.DetourHelper.get_Runtime()
   at MonoMod.RuntimeDetour.Hook..ctor(MethodBase from, MethodInfo to, Object target, HookConfig& config)
   at MonoMod.RuntimeDetour.Hook..ctor(MethodBase from, MethodInfo to, Object target, HookConfig config)
   at MonoMod.RuntimeDetour.Hook..ctor(MethodBase from, MethodInfo to, Object target)
   at MonoMod.RuntimeDetour.Hook..ctor(MethodBase method, Delegate to)
   at Terraria.ModLoader.Core.LoggingHooks.PrettifyStackTraceSources() in tModLoader\Terraria\ModLoader\Core\LoggingHooks.cs:line 38
   at Terraria.ModLoader.Logging.LogStartup(Boolean dedServ) in tModLoader\Terraria\ModLoader\Logging.cs:line 83
   at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs) in tModLoader\Terraria\Program.cs:line 185
   at MonoLaunch.<>c__DisplayClass2_0.<Main>b__0() in tModLoader\Terraria\MonoLaunch.cs:line 65
   at MonoLaunch.Main(String[] args) in tModLoader\Terraria\MonoLaunch.cs:line 72

Permission denied tModLoader.RuntimeErrorSeeLogsForFullTrace
[16:47:14] [Main Thread/WARN] [tML]: tModLoader.RuntimeErrorSilentlyCaughtException
System.ComponentModel.Win32Exception: Permission denied
   at MonoMod.RuntimeDetour.Platforms.DetourNativeLibcPlatform.SetMemPerms(IntPtr start, UInt64 len, MmapProts prot)
   at MonoMod.RuntimeDetour.Platforms.DetourNativeLibcPlatform.MakeWritable(IntPtr src, UInt32 size)
   at MonoMod.RuntimeDetour.DetourHelper.MakeWritable(IDetourNativePlatform plat, NativeDetourData detour)
   at MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform._HookSelftest(MethodInfo from, MethodInfo to)
   at MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform..ctor()
   at MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETPlatform..ctor()
   at MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETCorePlatform..ctor()
   at MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETCorePlatform.Create()
   at MonoMod.RuntimeDetour.DetourHelper.get_Runtime()
   at MonoMod.RuntimeDetour.Hook..ctor(MethodBase from, MethodInfo to, Object target, HookConfig& config)
   at MonoMod.RuntimeDetour.Hook..ctor(MethodBase from, MethodInfo to, Object target, HookConfig config)
   at MonoMod.RuntimeDetour.Hook..ctor(MethodBase from, MethodInfo to, Object target)
   at MonoMod.RuntimeDetour.Hook..ctor(MethodBase method, Delegate to)
   at Terraria.ModLoader.Core.LoggingHooks.PrettifyStackTraceSources() in tModLoader\Terraria\ModLoader\Core\LoggingHooks.cs:line 38
   at Terraria.ModLoader.Logging.LogStartup(Boolean dedServ) in tModLoader\Terraria\ModLoader\Logging.cs:line 83
   at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs) in tModLoader\Terraria\Program.cs:line 185
   at MonoLaunch.<>c__DisplayClass2_0.<Main>b__0() in tModLoader\Terraria\MonoLaunch.cs:line 65
   at MonoLaunch.Main(String[] args) in tModLoader\Terraria\MonoLaunch.cs:line 72

[16:47:14] [Main Thread/FATAL] [Terraria]: Failed to Handle Save Data
System.ComponentModel.Win32Exception (13): Permission denied
   at MonoMod.RuntimeDetour.Platforms.DetourNativeLibcPlatform.SetMemPerms(IntPtr start, UInt64 len, MmapProts prot)
   at MonoMod.RuntimeDetour.Platforms.DetourNativeLibcPlatform.MakeWritable(IntPtr src, UInt32 size)
   at MonoMod.RuntimeDetour.DetourHelper.MakeWritable(IDetourNativePlatform plat, NativeDetourData detour)
   at MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform._HookSelftest(MethodInfo from, MethodInfo to)
   at MonoMod.RuntimeDetour.Platforms.DetourRuntimeILPlatform..ctor()
   at MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETPlatform..ctor()
   at MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETCorePlatform..ctor()
   at MonoMod.RuntimeDetour.Platforms.DetourRuntimeNETCorePlatform.Create()
   at MonoMod.RuntimeDetour.DetourHelper.get_Runtime()
   at MonoMod.RuntimeDetour.Hook..ctor(MethodBase from, MethodInfo to, Object target, HookConfig& config)
   at MonoMod.RuntimeDetour.Hook..ctor(MethodBase from, MethodInfo to, Object target, HookConfig config)
   at MonoMod.RuntimeDetour.Hook..ctor(MethodBase from, MethodInfo to, Object target)
   at MonoMod.RuntimeDetour.Hook..ctor(MethodBase method, Delegate to)
   at Terraria.ModLoader.Core.LoggingHooks.PrettifyStackTraceSources() in D:\a\tModLoader\tModLoader\src\tModLoader\Terraria\ModLoader\Core\LoggingHooks.cs:line 38
   at Terraria.ModLoader.Logging.LogStartup(Boolean dedServ) in D:\a\tModLoader\tModLoader\src\tModLoader\Terraria\ModLoader\Logging.cs:line 82
   at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs) in D:\a\tModLoader\tModLoader\src\tModLoader\Terraria\Program.cs:line 185
[16:47:14] [Main Thread/DEBUG] [tML]: Native Resolve: FNA, Version=22.5.0.0, Culture=neutral, PublicKeyToken=null -> SDL2
[16:47:14] [Main Thread/DEBUG] [tML]:   attempting load /Users/nemo/Applications/tModLoader/Libraries/Native/OSX/libSDL2-2.0.0.dylib
Unable to load shared library '/Users/nemo/Applications/tModLoader/Libraries/Native/OSX/libSDL2-2.0.0.dylib' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(/Users/nemo/Applications/tModLoader/Libraries/Native/OSX/libSDL2-2.0.0.dylib, 0x0001): tried: '/Users/nemo/Applications/tModLoader/Libraries/Native/OSX/libSDL2-2.0.0.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/Users/nemo/Applications/tModLoader/Libraries/Native/OSX/libSDL2-2.0.0.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')) tModLoader.RuntimeErrorSeeLogsForFullTrace
[16:47:14] [Main Thread/WARN] [tML]: tModLoader.RuntimeErrorSilentlyCaughtException
System.DllNotFoundException: Unable to load shared library '/Users/nemo/Applications/tModLoader/Libraries/Native/OSX/libSDL2-2.0.0.dylib' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(/Users/nemo/Applications/tModLoader/Libraries/Native/OSX/libSDL2-2.0.0.dylib, 0x0001): tried: '/Users/nemo/Applications/tModLoader/Libraries/Native/OSX/libSDL2-2.0.0.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/Users/nemo/Applications/tModLoader/Libraries/Native/OSX/libSDL2-2.0.0.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
   at System.Runtime.InteropServices.NativeLibrary.LoadFromPath(String libraryName, Boolean throwOnError)
   at System.Runtime.InteropServices.NativeLibrary.LoadFromPath(String libraryName, Boolean throwOnError)
   at System.Runtime.InteropServices.NativeLibrary.Load(String libraryPath)
   at MonoLaunch.ResolveNativeLibrary(Assembly assembly, String name) in tModLoader\Terraria\MonoLaunch.cs:line 96
   at System.Runtime.Loader.AssemblyLoadContext.GetResolvedUnmanagedDll(Assembly assembly, String unmanagedDllName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUnmanagedDllUsingEvent(String unmanagedDllName, Assembly assembly, IntPtr gchManagedAssemblyLoadContext)
   at SDL2.SDL.INTERNAL_SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, Byte* title, Byte* message, IntPtr window)
   at SDL2.SDL.INTERNAL_SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, Byte* title, Byte* message, IntPtr window)
   at SDL2.SDL.SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, String title, String message, IntPtr window) in D:\a\tModLoader\tModLoader\FNA\lib\SDL2-CS\src\SDL2.cs:line 1317
   at Terraria.ModLoader.UI.Interface.MessageBoxShow(String text, String caption) in tModLoader\Terraria\ModLoader\UI\Interface.cs:line 451
   at Terraria.ModLoader.UI.Interface.MessageBoxShow(Exception e, String caption, Boolean generateTip) in tModLoader\Terraria\ModLoader\UI\Interface.cs:line 471
   at Terraria.Program.DisplayException(Exception e) in tModLoader\Terraria\Program.cs:line 276
   at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs) in tModLoader\Terraria\Program.cs:line 185
   at MonoLaunch.<>c__DisplayClass2_0.<Main>b__0() in tModLoader\Terraria\MonoLaunch.cs:line 65
   at MonoLaunch.Main(String[] args) in tModLoader\Terraria\MonoLaunch.cs:line 72

Steam version exit without notice after launch:

https://user-images.githubusercontent.com/38759782/175903725-b003394e-8508-4d78-9ddc-ba2fbea87630.mov

System information:

~/Applications/tModLoader                                                                                                                                    17:09:44
❯ uname -a
Darwin nemo-a2348.local 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T8101 arm64

~/Applications/tModLoader                                                                                                                                    17:09:45
❯ neofetch
                    'c.          nemo@nemo-a2348.local
                 ,xNMM.          ---------------------
               .OMMMMo           OS: macOS 12.4 21F79 arm64
               OMMM0,            Host: Macmini9,1
     .;loddo:' loolloddol;.      Kernel: 21.5.0
   cKMMMMMMMMMMNWMMMMMMMMMM0:    Uptime: 1 day, 21 hours, 24 mins
 .KMMMMMMMMMMMMMMMMMMMMMMMWd.    Packages: 4 (brew)
 XMMMMMMMMMMMMMMMMMMMMMMMX.      Shell: zsh 5.8.1
;MMMMMMMMMMMMMMMMMMMMMMMM:       Resolution: 1920x1080, 1366x1024
:MMMMMMMMMMMMMMMMMMMMMMMM:       DE: Aqua
.MMMMMMMMMMMMMMMMMMMMMMMMX.      WM: Quartz Compositor
 kMMMMMMMMMMMMMMMMMMMMMMMMWd.    WM Theme: Blue (Light)
 .XMMMMMMMMMMMMMMMMMMMMMMMMMMk   Terminal: iTerm2
  .XMMMMMMMMMMMMMMMMMMMMMMMMK.   Terminal Font: MesloLGS-NF-Regular 13
    kMMMMMMMMMMMMMMMMMMMMMMd     CPU: Apple M1
     ;KMMMMMMMWXXWMMMMMMMk.      GPU: Apple M1
       .cooc,.    .,coo:.        Memory: 1655MiB / 8192MiB

Reference to #2559

overdramaticpanromantic commented 10 months ago

I'm having issues with performance. On a non-M1 Mac, I consistently get 60 FPS, even during very straining bossfights. On an M1 Mac, I get ranging from 10-15, with straining bossfights reducing this to lower than 5. I'm unsure if this is the right place to put this comment; if I should go elsewhere, please redirect me.

JavidPack commented 10 months ago

I'm having issues with performance. On a non-M1 Mac, I consistently get 60 FPS, even during very straining bossfights. On an M1 Mac, I get ranging from 10-15, with straining bossfights reducing this to lower than 5. I'm unsure if this is the right place to put this comment; if I should go elsewhere, please redirect me.

Your best bet consult the FAQ for some things to try. After that come to the #support-forum channel in our Discord chat. Be sure to post your logs when asking for support.

Chicken-Bones commented 10 months ago

@Mirsario you might be able to instruct this user on how to get a command line dotTrace.

overdramaticpanromantic commented 10 months ago

I'm having issues with performance. On a non-M1 Mac, I consistently get 60 FPS, even during very straining bossfights. On an M1 Mac, I get ranging from 10-15, with straining bossfights reducing this to lower than 5. I'm unsure if this is the right place to put this comment; if I should go elsewhere, please redirect me.

Your best bet consult the FAQ for some things to try. After that come to the #support-forum channel in our Discord chat. Be sure to post your logs when asking for support.

Hi! I've already checked out the FAQ, which doesn't have anything M1 specific, and no other tips seem to fix my performance problems. I also already opened a forum in #support-forum; it's linked here. Frame skip is what I must use for the time being, I suppose.

Mirsario commented 10 months ago

@Mirsario you might be able to instruct this user on how to get a command line dotTrace.

@overdramaticpanromantic That should be a matter of:

Eventually we'll at the very least make a mod to simplify this through an in-game command, if not put that inside TML.

devraza commented 1 month ago

I was having the same issue but adding /gldevice:Vulkan to my command-line launch arguments in Steam fixed the issue mostly. I went from around 6 FPS to a consistent 40FPS, which is playable but still somewhat underwhelming for my hardware (M1 MacBook Air).