Required Information in all Technical Support Requests
Please ensure that you provide the following information for all questions posted in this Technical Support forum.
Version and language (e.g. 8.00 Hotfix 3, English, etc.).
Whether or not your game is modified using any third party scripts or mods (see note below).
The game start you originally selected for the game in which the problem occurred.
Exact nature of the problem, where and when it occurs and what you were doing at the time.
Any possibly relevant changes you have made to your game, system, or software before the issue occurred.
Where appropriate, additional symptoms, error messages, links to saves, screenshots and crash dump files (see this Wiki entry).
Your system specifications in the form of a DxDiag report and vulkaninfo (see this Wiki entry).
Failure to provide all this information will make it pretty much impossible for people to help you and may mean that it takes longer for your problem to be identified and hopefully solved. So please don't waste your own time and everyone else's by just posting something like "My game freezes. Help!!!".
If you are supplying information that will not conveniently fit into posts in this forum (approx 70,000 character limit per post), in the worst case you can split long text files across 2 consecutive posts, or ideally you can upload the data to a reputable public fileshare site (a few examples are Google Drive, DropBox or PasteBin, etc) but please don't use sites that spam advertising or require registration for downloads. Please use in your post the open public sharing link to your file(s) that will not require any account or registration for others to download.
Note: Support for third party modifications must be provided by the authors of those modifications, and any requests for such support should be posted in the appropriate thread in the Scripts and Modding forum.
This is difficult to describe so I don't expect much relevant discussion online, but basically, I noticed that I can generate a bad lag spike reliably when I switch from/to the game while I am playing.
The game being modded or not doesn't seem to matter since this is probably an engine-level issue (explained below).
This was observed in 8.00 (590967) on a Win11 PC.
Steps to reproduce:
Start the game
In Graphics Settings, make the game display in full screen mode
Enter the main game (use the standard X4 Galaxy for best effect)
Wait until the game is fully loaded
While the game is still running, Alt+Tab away from the game
Wait a while (e.g. 15 - 30 seconds)
Alt-Tab back into the game
Lag (!!!)
This lag spike is very intense. On weaker machines this may or may not directly cause a crash.
Pausing the game when the lag spike has happened doesn't seem to ease the lag spike.
Interestingly, pausing the game first and then Alt-Tab, does not trigger this lag spike.
The future awaits.
X4 Foundations mods: Civilian Fleets: (Obsolete for X4 7.0+) Managing your civilian ships has never been easier. Station Logistics: Managing your station networks has never been easier. Market Discovery: Find Black Market Traders; also rerolls them. Logistics Optimization: Improve your station traders; improve your trade stations! Logistics Guidance: Manually adjust station logistics efficiency.
You'll have to link an uploaded DxDiag file for the devs to look at for them to have a chance at understanding a technical problem.
That said, is this an issue that started with 8.00 (considering it's reported as a consistent and obvious issue) or did it not coincide with the game update (or whenever it was you patched your game to the new version). If the behaviour doesn't coincide with the update (or one of the subsequent hotfix patches), did it perhaps coincide with a Windows update? I don't want to ignorantly point fingers but I've read quite a bit of news about one or two recent Windows 11 updates that reportedly degraded performance in games quite noticably and if the technical issue consistently occurs after alt-tabbing it could very well be a problem of WIndows being slow at allocating system resources to the game (with the game being on the CPU intensive side, this could cause major performance dips if your CPU isn't being tasked properly). The performance behaviour with pausing the game does seem to validate my suspicion here (as pausing after alt-tabbing would still require the game to load up all the data and the pause amy not go in effect due to the performance lag, whilst having the game paused before alt-tabbing and then back would mean there's much less immediate CPU demand when going back).
I'm making this post to see if it's just an issue specific to me, or in fact this is a real general problem. Granted, most of the time when we play games, it's unlikely to just Alt+Tab away; we would focus on the game and just not do Alt-Tab.
That said, I have a guess of what might be happening.
If I pause and then Alt+Tab, then the game will very clearly know there was a "game pause" event, and will stop all calculations correctly.
Borrowing my past experience with X Rebirth, if I am in Windowed Display or in Borderless Window and keep the game running while I Alt-Tab, then the game will still continue to run, but the graphics display will render at significantly-reduced FPS. This is OK since by doing Alt-Tab, we are no longer interested in the X4 Foundations game at the moment. But the key is, the game is still running in this case.
Now, for Fullscreen Display, when I Alt-Tab, the game screen is fully hidden, and all playing sound files are instantly paused. This is the interesting part. Looking at how the Mission Director has these sleep/wait calls available, I am guessing that the MD actually schedules some sort of "continue this code after this system time" instruction under the hood. This normally is not a problem, but here in this case, since we just directly jump away from the game, the MD doesn't know about this, and when we come back later after some time, the MD panics because a long time seemingly has passed without the MD's knowledge, and so the MD must use all efforts to catch up and deal with all the "unfinished" mess. This then causes the mentioned "lag spike".
Something similar also happens in the Unity Engine, where if I Alt+Tab away from a fullscreen game (e.g. Alt-Tab away from RimWorld in fullscreen mode), and I have some code that triggers every tick, I can very easily notice that the "delta time after this tick" is insanely high after that Alt-Tab move. I know this because I noticed this while modding RimWorld and counting time during fullscreen mode.
This could be a general Windows thing.
---------------
I vaguely remember X Rebirth actually have a mechanism for this situation, where if the game was somehow Alt-Tab away, or other shenanigans, then when we return to the XR game, the XR engine actually shows a game splash screen and hides everything else, until some seconds later where presumably all kinds of checking and queues are cleared, and then we will return to a Game Paused screen, regardless if the game was actually paused before we Alt-Tab away.
Something similar could/should also be done to X4. This should somehow be a known technique somewhere in EgoSoft.
The future awaits.
X4 Foundations mods: Civilian Fleets: (Obsolete for X4 7.0+) Managing your civilian ships has never been easier. Station Logistics: Managing your station networks has never been easier. Market Discovery: Find Black Market Traders; also rerolls them. Logistics Optimization: Improve your station traders; improve your trade stations! Logistics Guidance: Manually adjust station logistics efficiency.
On Windows 10 and 11 "fullscreen" is deprecated due to the use of fullscreen optimisation. All applications should use "borderless windowed" fullscreen mode, and that is the only presentation mode available for DX12 applications. Vulkan (what X4 uses for graphics) still offers an exclusive fullscreen display path but using this can have issues on Windows 10/11 (sometimes the driver tries to obey it and ignore using fullscreen optimisation) and might explain some of the problems you are encountering.
There are command line arguments you can use to have X4 keep running in the background. The behaviour is disabled by default to save CPU and GPU resources when not actively playing.
The stutter you describe could be due to memory paging. Check both RAM and VRAM usage.