X2CommunityCore / xcom2-launcher

The Alternative Mod Launcher (AML) is a replacement for the default game launchers from XCOM 2 and XCOM Chimera Squad.
GNU General Public License v3.0
347 stars 51 forks source link

Crash upon starting #289

Open TheRealAyCe opened 2 years ago

TheRealAyCe commented 2 years ago

AML Version: 1.5.0.0?

Description Crash upon launching the game. It always crashes when launching. The game launched, but then also crashed (because it was not focused?).

Got this from the Windows events view:

Beschreibung: Der Prozess wurde aufgrund einer unbehandelten Ausnahme beendet. Ausnahmeinformationen: System.AccessViolationException bei Steamworks.NativeMethods.SteamAPI_ManualDispatch_GetNextCallback(Steamworks.HSteamPipe, IntPtr) bei Steamworks.CallbackDispatcher.RunFrame(Boolean) bei XCOM2Launcher.Classes.Steam.SteamAPIWrapper.RunCallbacks() bei System.Windows.Forms.Timer.OnTick(System.EventArgs) bei System.Windows.Forms.Timer+TimerNativeWindow.WndProc(System.Windows.Forms.Message ByRef) bei System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr) bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef) bei System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32, Int32) bei System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext) bei System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext) bei XCOM2Launcher.Program.Main()

AML.log

RevZero commented 2 years ago

You wrote that you got the Exception details from the Windows event log. Does AML throw an actual error window/message on its own? AML crashing and XCOM crashing is normally not related. But windows logs may track a crash it in that way, because AML is attached to the game process using the steam API. Do you have the "Close after launch" setting enabled in AML? If yes, disable it and test if AML stays open after launching the game. Maybe it just closes and appears to be crashing, while only the game does.

TheRealAyCe commented 2 years ago

AML just crashes with the windows "Has encountered an unexpected problem and needs to be terminated" thing. I've learned that you can usually get the stacktrace from the Windows event log, so I did that.

AML crashes before XCOM and XCOM only crashed later because I wasn't tabbed in I think. For whatever reason it does that, idk. When I make an effort to have the XCOM window focused, XCOM2 works normally.

"Close after launch" is not checked.

I should add that "when launching the game" means "when I press the button 'Run War of the Chosen' in the UI".

RevZero commented 2 years ago

Does this also happen with zero mods enabled? Does XCOM start normally when launching it through Steam?

TheRealAyCe commented 2 years ago

I unticked all the mods and the launcher still crashes when starting.

XCOM2 launches normally through Steam.

RevZero commented 2 years ago

Hmm. Try moving your AML folder from ..\XCom2-WarOfTheChosen\XComGame\XCOM2_AlternativeModLauncher_1.5.0-beta2\ to the desktop ..\Desktop\XCOM2_AlternativeModLauncher_1.5.0-beta2\.

Also temporarily disable any Anti-Virus or Anti-Malware tools that you may have running.

TheRealAyCe commented 2 years ago

Still crashes :(

RevZero commented 2 years ago

I assume you are on Windows 10? Did you try running AML as admin?

TheRealAyCe commented 2 years ago

Win 7, also crashes as admin.

RevZero commented 2 years ago

Did you manage to resolve this? @TheRealAyCe

TheRealAyCe commented 2 years ago

Nope, but the game starts anyway, so it's not "game breaking". Just weird to have the program crash in sync with the game launching.

RevZero commented 2 years ago

This is strange. What happens if you enable "Close after launch". Does it manage to close properly or does the crash happen instantly?

Its definitely the unmanaged Steam API code causing the AccessViolationException while processing callbacks. But I have no clue why this is happening and there is not much I could do about it.

TheRealAyCe commented 2 years ago

With "Close after launch" no crash happens and the app closes.

In https://github.com/X2CommunityCore/xcom2-launcher/blob/c6ae259ad03dffaa63c233e2da66c976a08dabb7/xcom2-launcher/xcom2-launcher/Classes/XCOM/Xcom2Env.cs in RunWotC() it calls Shutdown(). But the timer is still processing callbacks meanwhile. And why does the app use Init() in many places? I would think calling it once at the start should be enough? Maybe the combination of Init() everywhere and calling Shutdown() there while executing the callbacks later kills it?

RevZero commented 2 years ago

@TheRealAyCe Processing callbacks after calling shutdown is a good point and may be an issue indeed. I will take a look at it when I find the time. The initial Steam API implementation was done before I was on board, so I can't tell you the reasoning behind how some things were implemented.

forealdo25 commented 1 year ago

Sorry to necro an old post, but I'm actually having the same issue. Same text in Event Viewer as well.

Application: XCOM2 Launcher.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.AccessViolationException at Steamworks.NativeMethods.SteamAPI_ManualDispatch_GetNextCallback(Steamworks.HSteamPipe, IntPtr) at Steamworks.CallbackDispatcher.RunFrame(Boolean) at XCOM2Launcher.Classes.Steam.SteamAPIWrapper.RunCallbacks() at System.Windows.Forms.Timer.OnTick(System.EventArgs) at System.Windows.Forms.Timer+TimerNativeWindow.WndProc(System.Windows.Forms.Message ByRef) at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef) at System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32, Int32) at System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext) at System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext) at XCOM2Launcher.Program.Main()

forealdo25 commented 1 year ago

I also got these errors in Event Viewer

Faulting application name: XCOM2 Launcher.exe, version: 1.5.0.0, time stamp: 0x624207c2 Faulting module name: steamclient64.dll_unloaded, version: 7.72.78.29, time stamp: 0x639b916a Exception code: 0xc0000005 Fault offset: 0x00000000007e2cb0 Faulting process id: 0x0x984 Faulting application start time: 0x0x1D92659F0AAEB51 Faulting application path: C:\Users\User\Desktop\XCOM2_AlternativeModLauncher_1.5.0\XCOM2 Launcher.exe Faulting module path: steamclient64.dll Report Id: 8f448b4f-9c6b-46dc-978e-d1179a5318d1 Faulting package full name: Faulting package-relative application ID:

caseyjp11 commented 1 year ago

This is also occurring with Proton/Steam on Linux. The error thrown is the same each time. (Via Journalctl) Kandalf plasmashell[756909]: 2023-07-28 12:28:16,853 [1] INFO Xcom2Env:0 - Starting WotC Jul 28 12:28:17 Kandalf plasmashell[756909]: Jul 28 12:28:17 Kandalf plasmashell[756909]: ================================================================= Jul 28 12:28:17 Kandalf plasmashell[756909]: Native Crash Reporting Jul 28 12:28:17 Kandalf plasmashell[756909]: ================================================================= Jul 28 12:28:17 Kandalf plasmashell[756909]: Got a UNKNOWN while executing native code. This usually indicates Jul 28 12:28:17 Kandalf plasmashell[756909]: a fatal error in the mono runtime or one of the native libraries Jul 28 12:28:17 Kandalf plasmashell[756909]: used by your application. Jul 28 12:28:17 Kandalf plasmashell[756909]: ================================================================= Jul 28 12:28:17 Kandalf plasmashell[756909]: Jul 28 12:28:17 Kandalf plasmashell[756909]: ================================================================= Jul 28 12:28:17 Kandalf plasmashell[756909]: Managed Stacktrace: Jul 28 12:28:17 Kandalf plasmashell[756909]: ================================================================= Jul 28 12:28:17 Kandalf plasmashell[756909]: at <0xffffffff> Jul 28 12:28:17 Kandalf plasmashell[756909]: at Steamworks.NativeMethods:SteamAPI_ManualDispatch_GetNextCallback <0x000b5> Jul 28 12:28:17 Kandalf plasmashell[756909]: at Steamworks.CallbackDispatcher:RunFrame <0x00b1a> Jul 28 12:28:17 Kandalf plasmashell[756909]: at Steamworks.SteamAPI:RunCallbacks <0x0003a> Jul 28 12:28:17 Kandalf plasmashell[756909]: at XCOM2Launcher.Classes.Steam.SteamAPIWrapper:RunCallbacks <0x0009a> Jul 28 12:28:17 Kandalf plasmashell[756909]: at <>c:<.ctor>b__10_2 <0x0003a> Jul 28 12:28:17 Kandalf plasmashell[756909]: at System.Windows.Forms.Timer:OnTick <0x00059> Jul 28 12:28:17 Kandalf plasmashell[756909]: at TimerNativeWindow:WndProc <0x000a3> Jul 28 12:28:17 Kandalf plasmashell[756909]: at System.Windows.Forms.NativeWindow:Callback <0x000bd> Jul 28 12:28:17 Kandalf plasmashell[756909]: at System.Windows.Forms.NativeWindow:Callback <0x000a2> Jul 28 12:28:17 Kandalf plasmashell[756909]: at System.Windows.Forms.NativeWindowProc:Callback <0x00122> Jul 28 12:28:17 Kandalf plasmashell[756909]: at System.Windows.Forms.NativeWindowProc:Callback <0x0009a> Jul 28 12:28:17 Kandalf plasmashell[756909]: at <0xffffffff> Jul 28 12:28:17 Kandalf plasmashell[756909]: at System.Windows.Forms.UnsafeNativeMethods:DispatchMessageW <0x000a9> Jul 28 12:28:17 Kandalf plasmashell[756909]: at ComponentManager:System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop <0x0096a> Jul 28 12:28:17 Kandalf plasmashell[756909]: at ThreadContext:RunMessageLoopInner <0x00b34> Jul 28 12:28:17 Kandalf plasmashell[756909]: at ThreadContext:RunMessageLoop <0x00082> Jul 28 12:28:17 Kandalf plasmashell[756909]: at ThreadContext:RunMessageLoop <0x000aa> Jul 28 12:28:17 Kandalf plasmashell[756909]: at System.Windows.Forms.Application:Run <0x00092> Jul 28 12:28:17 Kandalf plasmashell[756909]: at XCOM2Launcher.Program:Main <0x0071a> Jul 28 12:28:17 Kandalf plasmashell[756909]: at System.Object:runtime_invoke_void <0x000a4> Jul 28 12:28:17 Kandalf plasmashell[756909]: =================================================================