Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close after lauch setting doesn't work #317

Open
Ziktofel opened this issue Apr 2, 2022 · 4 comments · Fixed by #345
Open

Close after lauch setting doesn't work #317

Ziktofel opened this issue Apr 2, 2022 · 4 comments · Fixed by #345
Labels
Status: Implemented Indicates that the issue has been handled but may not have been merged. Type: Bug
Milestone

Comments

@Ziktofel
Copy link

Ziktofel commented Apr 2, 2022

AML Version: 1.5.0

Description
The close after launch setting doesn't work: The launcher always closes regardless of the setting

@Ziktofel Ziktofel added Status: Review Verify bug or check feasibility of a new feature. Type: Bug labels Apr 2, 2022
@Tepa00
Copy link

Tepa00 commented Apr 2, 2022

I had similar behavior in 1.5 beta 2, disabling Send anonymous error reports in AML settings stopped it from closing on it's own. Can you try if doing that makes a difference?

@Dragon-32
Copy link

Didn't get this in the beta but did with the full 1.5.0 release

What I found fixed it was setting AML's "close on launch" to true and starting the game. Exit game. Re-start AML and then set "close on launch" to False. That seems to have fixed it.

I think when I started with a fresh settings .xml file the setting was followed, only when I used my migrated settings did it fail. I compared a freshly generated settings file with my historic one using Winmerge and couldn't see any meaningful differences about the config option.

@Iridar
Copy link

Iridar commented Dec 7, 2022

I had this with 1.5.0 stable on a fresh installation of X2 and AML on Win 10. Launching AML as admin seems to have fixed it.

remcoros added a commit to remcoros/xcom2-launcher that referenced this issue Jul 31, 2023
remcoros added a commit to remcoros/xcom2-launcher that referenced this issue Jul 31, 2023
RevZero pushed a commit that referenced this issue Aug 14, 2023
Should fix #317, fix #289 and fix #268.

* Replaced SteamAPIWrapper with 'SteamManager', which is now responsible for calling 'RunCallbacks' in a timer. Except for startup/shutdown, no one should call init/runcallbacks/shutdown manually.
* Fixed an issue where callbacks (not callresults!) were registered multiple times, resulting in ever growing steamworks callbacks. * Wrapped some steam callbacks (CallResults) into an async helper function using proper async/await constructs.
* Tweaks to mod list being non responsive (also prevent unnecessarily refreshing/redrawing it)
* Load mod dependencies as part of the GetDetails batch requests
* Refresh mod list filter after hide/unhide to update mod list properly
@RevZero RevZero added Status: Accepted Confirmed bug or useful feature that should be worked on. and removed Status: Review Verify bug or check feasibility of a new feature. labels Aug 14, 2023
@RevZero RevZero added this to the v1.6 milestone Aug 14, 2023
@RevZero RevZero added Status: Implemented Indicates that the issue has been handled but may not have been merged. and removed Status: Accepted Confirmed bug or useful feature that should be worked on. labels Aug 14, 2023
@srinathupadhyayula
Copy link

srinathupadhyayula commented Jun 11, 2024

The Issue here is that it crashes when running the game, as it is accessing memory it should not be...

Here is the callstack of the error:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Steamworks.NativeMethods.SteamAPI_ManualDispatch_GetNextCallback(HSteamPipe hSteamPipe, IntPtr pCallbackMsg)
   at Steamworks.CallbackDispatcher.RunFrame(Boolean isGameServer)
   at Steamworks.SteamAPI.RunCallbacks()
   at XCOM2Launcher.Classes.Steam.SteamAPIWrapper.RunCallbacks() in E:\C#\xcom2-launcher-git\xcom2-launcher\xcom2-launcher\xcom2-launcher\Classes\Steam\SteamAPIWrapper.cs:line 17
   at XCOM2Launcher.Forms.MainForm.<>c.<.ctor>b__10_2(Object sender, EventArgs e) in E:\C#\xcom2-launcher-git\xcom2-launcher\xcom2-launcher\xcom2-launcher\Forms\MainForm.cs:line 74
   at System.Windows.Forms.Timer.OnTick(EventArgs e)
   at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at XCOM2Launcher.Program.Main() in E:\C#\xcom2-launcher-git\xcom2-launcher\xcom2-launcher\xcom2-launcher\Program.cs:line 138

The piece of code causing the crash is on line 16 of SteamAPIWrapper.cs in method RunCallbacks() where it is calling SteamAPI.RunCallbacks();

The Problem here is potentially(I am about 99% on this) caused by a combination of 2 things.

  1. In Xcom2Env.cs on line 117, when the game is started, SteamAPIWrapper.Shutdown(); is called, which in turn is calling return SteamAPI.Init(); and therefore shutting down SteamAPI(whatever that means).
  2. However, in MainForm.cs on line 73, in its constructor, there is a timer that is set to run every 10 seconds, which calls the method SteamAPIWrapper.RunCallbacks();. This is the cause of the crash as the timer continues to call this method even after SteamAPI is shoutdown.

Here is the offending code:

           // Run callbacks
            var t1 = new Timer();
            t1.Tick += (sender, e) => { SteamAPIWrapper.RunCallbacks(); }; // This is the cause of the crash
            t1.Interval = 10;
            t1.Start();

In my local testing, commenting out the line SteamAPIWrapper.Shutdown(); in Xcom2Env mitigates the issue. However, I am still fumbling and stumbling through the code, and have no idea what the consequences of this can be, and why Shutdown() was being called in the first place.

RevZero pushed a commit that referenced this issue Jul 5, 2024
Should fix #317, fix #289 and fix #268.

* Replaced SteamAPIWrapper with 'SteamManager', which is now responsible for calling 'RunCallbacks' in a timer. Except for startup/shutdown, no one should call init/runcallbacks/shutdown manually.
* Fixed an issue where callbacks (not callresults!) were registered multiple times, resulting in ever growing steamworks callbacks. * Wrapped some steam callbacks (CallResults) into an async helper function using proper async/await constructs.
* Tweaks to mod list being non responsive (also prevent unnecessarily refreshing/redrawing it)
* Load mod dependencies as part of the GetDetails batch requests
* Refresh mod list filter after hide/unhide to update mod list properly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Implemented Indicates that the issue has been handled but may not have been merged. Type: Bug
Projects
None yet
6 participants