Skip to content

[Bug]: Object was garbage collected in IL2CPP domain #92

@not-so-sure

Description

@not-so-sure

Are you on the latest version of UnityExplorer?

  • Yes, I'm on the latest version of UnityExplorer.

Will other mods work? (Not mods that change settings, but small mods that access game objects, etc.)

  • Yes, work fine!!

Which release are you using?

MelonLoader IL2CPP CoreCLR

Which game did this occur on?

Iron Nest Unity 6000.3.9f

Does this game support mods?

  • Yes support!!

Describe the issue.

The main issue is around the Object was garbage collected in IL2CPP domain

Already tried to:

  1. Try to use a fork of BepInEx 6v for Unity 6
  2. Tried dozen versions of UnityExplorer (even mono and later cinematic)
  3. Been in a VC with another person trying to figure out it
  4. We searched help from both BepInEx and MelonLoader mod developers, some said it was working for them
  5. Tried using the most recent available artifact, did not work aswell
  6. Tried figuring out where IL2CPP collects the 'object'

I will be attaching my lastest file, this is pure MelonLoader IL2CPP in the most recent artifact from both MelonLoader IL2CPP and UnityExplorer.

I tried using other mods for the MelonLoader, which all of them worked out of box, no need for modifications, so this only confirms its a problem of the UnityExplorer, as well while not so important, it was tested in more than a device.

As for mods that changes heavily the game, I ran some test scripts that changed all game audios and one who changed all texts, directly interacting with game objects.

Relevant log output

[22:53:05.272] ------------------------------
[22:53:05.281] MelonLoader v0.7.2-ci.2398 Open-Beta
[22:53:05.282] OS: Windows 11
[22:53:05.283] Hash Code: C331597B30114AB34F582635B08980EA70ACC0411ECD15D122BE5D1ABC63EB42
[22:53:05.283] ------------------------------
[22:53:05.283] Game Type: Il2cpp
[22:53:05.284] Game Arch: x64
[22:53:05.284] ------------------------------
[22:53:05.284] Command-Line: 
[22:53:05.284] ------------------------------
[22:53:05.285] Core::BasePath = C:\Program Files (x86)\Steam\steamapps\common\IRON NEST Heavy Turret Simulator Demo
[22:53:05.287] Game::BasePath = C:\Program Files (x86)\Steam\steamapps\common\IRON NEST Heavy Turret Simulator Demo
[22:53:05.302] Game::DataPath = C:\Program Files (x86)\Steam\steamapps\common\IRON NEST Heavy Turret Simulator Demo\Iron Nest Heavy Turret Simulator_Data
[22:53:05.302] Game::ApplicationPath = C:\Program Files (x86)\Steam\steamapps\common\IRON NEST Heavy Turret Simulator Demo\Iron Nest Heavy Turret Simulator.exe
[22:53:05.302] Runtime Type: net6
[22:53:05.485] ------------------------------
[22:53:05.485] Game Name: Iron Nest: Heavy Turret Simulator
[22:53:05.486] Game Developer: Iron Nest
[22:53:05.490] Unity Version: 6000.3.9f1
[22:53:05.490] Game Version: 0.3.1
[22:53:05.490] ------------------------------

[22:53:06.912] Preferences Loaded!

[22:53:06.959] Loading UserLibs...
[22:53:07.003] ------------------------------
[22:53:07.048] Melon Assembly loaded: '.\UserLibs\UniverseLib.ML.IL2CPP.Interop.dll'
[22:53:07.048] SHA256 Hash: 'D977B01167D13B78B5953448A296F6C9F7FEDB6313EA0F585E5861D5D3542644'
[22:53:07.050] ------------------------------
[22:53:07.050] 0 UserLibs loaded.

[22:53:07.050] Loading Plugins...
[22:53:07.060] 0 Plugins loaded.

[22:53:08.244] Loading Il2CppAssemblyGenerator...
[22:53:08.330] [Il2CppAssemblyGenerator] Contacting RemoteAPI...
[22:53:08.613] [Il2CppAssemblyGenerator] Game Not Found on RemoteAPI Host (https://api.melonloader.com/api/v1/game/iron-nest-heavy-turret-simulator)
[22:53:08.613] [Il2CppAssemblyGenerator] RemoteAPI.DumperVersion = null
[22:53:08.614] [Il2CppAssemblyGenerator] RemoteAPI.ObfuscationRegex = null
[22:53:08.614] [Il2CppAssemblyGenerator] RemoteAPI.MappingURL = null
[22:53:08.615] [Il2CppAssemblyGenerator] RemoteAPI.MappingFileSHA512 = null
[22:53:08.622] [Il2CppAssemblyGenerator] Using Cpp2IL Version: 2022.1.0-pre-release.21
[22:53:08.622] [Il2CppAssemblyGenerator] Using Il2CppInterop Version = 1.5.1+dbaf825aab891ff1e1627bea691bde0a81d1ad98
[22:53:08.623] [Il2CppAssemblyGenerator] Using Unity Dependencies Version = 6000.3.9
[22:53:08.623] [Il2CppAssemblyGenerator] Using Deobfuscation Regex = null
[22:53:08.624] [Il2CppAssemblyGenerator] Cpp2IL is up to date.
[22:53:08.626] [Il2CppAssemblyGenerator] Cpp2IL.Plugin.StrippedCodeRegSupport is up to date.
[22:53:08.626] [Il2CppAssemblyGenerator] UnityDependencies is up to date.
[22:53:08.626] [Il2CppAssemblyGenerator] Checking GameAssembly...
[22:53:09.205] [Il2CppAssemblyGenerator] Assembly is up to date. No Generation Needed.

[22:53:09.208] Loading Mods...
[22:53:09.239] ------------------------------
[22:53:09.272] Melon Assembly loaded: '.\Mods\UnityExplorer.ML.IL2CPP.CoreCLR.dll'
[22:53:09.273] SHA256 Hash: 'A0DD50A028D0CEA13BB7CB4ADD96DD14C7DB90234518C3B7503768292975D7DC'

[22:53:09.587] ------------------------------
[22:53:09.588] UnityExplorer v4.13.2
[22:53:09.588] by Sinai, yukieiji
[22:53:09.589] Assembly: UnityExplorer.ML.IL2CPP.CoreCLR.dll
[22:53:09.589] ------------------------------
[22:53:09.589] ------------------------------
[22:53:09.590] 1 Mod loaded.

[22:53:12.776] [Il2CppInterop] Class::Init signatures have been exhausted, using a substitute!
[22:53:16.368] [Il2CppInterop] Registered mono type MelonLoader.Support.MonoEnumeratorWrapper in il2cpp domain
[22:53:16.478] Support Module Loaded: C:\Program Files (x86)\Steam\steamapps\common\IRON NEST Heavy Turret Simulator Demo\MelonLoader\Dependencies\SupportModules\Il2Cpp.dll
[22:53:16.541] [UnityExplorer] UnityExplorer 4.13.2 initializing...
[22:53:16.578] [UnityExplorer] [UniverseLib] UniverseLib 1.6.1 initializing...
[22:53:16.582] [Il2CppInterop] Registered mono type UniverseLib.UniversalBehaviour in il2cpp domain
[22:53:17.947] [UnityExplorer] [UniverseLib] THIS WARNING IS NOT BUG!!!! DON'T REPORT THIS!!!!!
 Can't cache type named <>c Error: System.TypeLoadException: GenericArguments[0], 'UnityEngine.UIElements.PointerStationaryEvent', on 'UnityEngine.UIElements.EventBase`1[T]' violates the constraint of type parameter 'T'.
   at System.RuntimeTypeHandle.GetDeclaringType(RuntimeType type)
   at System.RuntimeType.RuntimeTypeCache.GetEnclosingType()
   at System.RuntimeType.RuntimeTypeCache.GetNameSpace()
   at System.RuntimeType.get_Namespace()
   at UniverseLib.ReflectionUtility.CacheTypes(Assembly asm) in D:\a\UnityExplorer\UnityExplorer\UniverseLib\src\Reflection\ReflectionUtility.cs:line 126
[22:53:17.978] [Il2CppInterop] Registered mono type UniverseLib.Runtime.Il2Cpp.Il2CppManagedEnumerator in il2cpp domain
[22:53:18.013] [UnityExplorer] [UniverseLib] Finished UniverseLib initial setup.
[22:53:18.034] [Il2CppInterop] Registered mono type Il2CppInterop.Runtime.DelegateSupport+Il2CppToMonoDelegateReference in il2cpp domain
[22:53:18.070] [Il2CppInterop] Registered mono type UnityExplorer.ExplorerBehaviour in il2cpp domain
[22:53:18.122] [UnityExplorer] Initialized UnityCrashPrevention for: Canvas.get_renderingDisplaySize
[22:53:24.702] [Il2CppInterop] Registered mono type MelonLoader.Support.SM_Component in il2cpp domain
[22:53:24.738] Registered mono icall UnityEngine.Transform::SetAsLastSibling in il2cpp domain
[22:53:28.951] [UnityExplorer] [UniverseLib] Loaded Unhollowed modules in 10.963 seconds.
[22:53:29.324] [UnityExplorer] [UniverseLib] Setup deobfuscation cache in 0.372 seconds.
[22:53:29.388] [UnityExplorer] [UniverseLib] Initialized new InputSystem support.
[22:53:29.542] [UnityExplorer] [UniverseLib] 	 IL2CPP method has no corresponding pointer, aborting patch of UnityEngine.AssetBundle.UnloadAllAssetBundles
[22:53:29.560] [Il2CppInterop] Registered mono type UniverseLib.AssetBundle in il2cpp domain
[22:53:29.568] Registered mono icall UnityEngine.AssetBundle::LoadFromMemory_Internal in il2cpp domain
[22:53:29.585] [Il2CppInterop] During invoking native->managed trampoline
Il2CppInterop.Runtime.ObjectCollectedException: Object was garbage collected in IL2CPP domain
   at Il2CppInterop.Runtime.InteropTypes.Il2CppObjectBase.get_Pointer() in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/InteropTypes/Il2CppObjectBase.cs:line 32
   at Il2CppSystem.Span`1..ctor(Il2CppArrayBase`1 array)
   at UnityEngine.AssetBundle.LoadFromMemory_Internal(Il2CppStructArray`1 binary, UInt32 crc)
   at (il2cpp -> managed) LoadFromMemory_Internal(IntPtr , UInt32 , Il2CppMethodInfo* )
[22:53:29.585] [UnityExplorer] [UniverseLib] Could not load UniverseLib UI modern Bundle!
[22:53:29.635] [UnityExplorer] [UniverseLib] UniverseLib 1.6.1 initialized.
[22:53:29.645] [UnityExplorer] Unable to check for existence of DontDestroyOnLoad scene via Scene.GetNameInternal: System.ArgumentException: Object of type 'System.Int32' cannot be converted to type 'UnityEngine.SceneManagement.SceneHandle'.
   at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
   at System.Reflection.MethodBase.CheckArguments(StackAllocedArguments& stackArgs, ReadOnlySpan`1 parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at UnityExplorer.ObjectExplorer.SceneHandler.Init()
[22:53:29.645] [UnityExplorer] Falling back to checking loaded scenes for DontDestroyOnLoad via SceneManager.GetAllScenes(). This uses a deprecated API.
[22:53:29.647] [UnityExplorer] [UniverseLib] Exception invoking onInitialized callback! System.NotSupportedException: Method unstripping failed
   at UnityEngine.SceneManagement.SceneManager.GetAllScenes()
   at UnityExplorer.ObjectExplorer.SceneHandler.Init()
   at UnityExplorer.ExplorerCore.LateInit()
   at UniverseLib.Universe.InvokeOnInitialized(Action onInitialized) in D:\a\UnityExplorer\UnityExplorer\UniverseLib\src\Universe.cs:line 148
[22:53:29.664] Registered mono icall UnityEngine.Resources::FindObjectsOfTypeAll in il2cpp domain
[22:53:42.797] Preferences Saved!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions