ValveSoftware / Source-1-Games

Source 1 based games such as TF2 and Counter-Strike: Source
634 stars 74 forks source link

[Source 1 Engine][HL2/EP1/EP2] Network/UNC path access causing 1 minute hitch when transitioning level #2842

Open RedHaze opened 4 years ago

RedHaze commented 4 years ago

Affected Games Confirmed: Half-Life 2, Half-Life 2: Episode One, Half-Life 2: Episode Two I believe this affects all Source 1 Engine games, see later in the report for more info why.

Issue Description Whenever transitioning into a new map, the loading time seems to take approximately 60 seconds. This time frame is consistent, and I've narrowed it down to HL2.exe attempting to access the invalid network path \\MOD\\ via Process Monitor. I'm assuming Windows is attempting to find a computer named MOD and times out after 60 seconds. I'm pretty sure this was also the same reason the save hitch was occurring.

I've marked this issue primarily as affecting all Source 1 Engine games as per the following stack trace taken from Process Monitor when \\MOD\\ is accessed: image

From my little Source engine knowledge, it seems like only the Engine specific DLL's are touched. Please feel free to update the ticket title/labels if I'm wrong.

Reproduction

  1. Ensure the Workstation service is running. In an administrator command prompt, execute the following:
    net start Workstation
    • If this service is not running, the UNC path access will return immediately. Fortunately, this acts as a work-around for the time being.
  2. Launch Half-Life 2.
  3. Download and launch procmon and add a process filter for hl2.exe. Make sure Process Monitor isn't in capture mode (magnifying glass should have a red X on it).
  4. Load a map via console, for example:
    map d1_trainstation_02
  5. Activate capture in Process Monitor.
  6. Either get to the end of the map, but don't load the next one or force the change level based on the next map in the sequence, for example execute the following in console:
    changelevel2 d1_trainstation_03
  7. The game should take, at minimum, one minute to load the next map regardless of computer specifications.
  8. Once the game loads, stop the Process Monitor capture and search for the first occurrence of the string \\MOD\\.
  9. Notice the one minute gap between the last folder access and the access to \\MOD\\ image

System Information

Computer Information:
    Manufacturer:  Micro-Star International Co., Ltd.
    Model:  MS-7B58
    Form Factor: Desktop
    No Touch Input Detected

Processor Information:
    CPU Vendor:  GenuineIntel
    CPU Brand:  Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
    CPU Family:  0x6
    CPU Model:  0x9e
    CPU Stepping:  0xa
    CPU Type:  0x0
    Speed:  3696 Mhz
    12 logical processors
    6 physical processors
    HyperThreading:  Supported
    FCMOV:  Supported
    SSE2:  Supported
    SSE3:  Supported
    SSSE3:  Supported
    SSE4a:  Unsupported
    SSE41:  Supported
    SSE42:  Supported
    AES:  Supported
    AVX:  Supported
    AVX2:  Supported
    AVX512F:  Unsupported
    AVX512PF:  Unsupported
    AVX512ER:  Unsupported
    AVX512CD:  Unsupported
    AVX512VNNI:  Unsupported
    SHA:  Unsupported
    CMPXCHG16B:  Supported
    LAHF/SAHF:  Supported
    PrefetchW:  Unsupported

Operating System Version:
    Windows 10 (64 bit)
    NTFS:  Supported
    Crypto Provider Codes:  Supported 311 0x0 0x0 0x0

Video Card:
    Driver:  NVIDIA GeForce GTX 970
    DirectX Driver Name:  nvldumd.dll
    Driver Version:  26.21.14.3064
    DirectX Driver Version:  26.21.14.3064
    Driver Date: 5 5 2019
    OpenGL Version: 4.6
    Desktop Color Depth: 32 bits per pixel
    Monitor Refresh Rate: 119 Hz
    DirectX Card: NVIDIA GeForce GTX 970
    VendorID:  0x10de
    DeviceID:  0x13c2
    Revision:  0xa1
    Number of Monitors:  2
    Number of Logical Video Cards:  2
    No SLI or Crossfire Detected
    Primary Display Resolution:  1920 x 1080
    Desktop Resolution: 3840 x 1080
    Primary Display Size: 20.91" x 11.77" (23.98" diag)
                                            53.1cm x 29.9cm (60.9cm diag)
    Primary Bus: PCI Express 16x
    Primary VRAM: 4095 MB
    Supported MSAA Modes:  2x 4x 8x 

Sound card:
    Audio device: Speakers (2- Schiit Modi Uber)

Memory:
    RAM:  16338 Mb

Miscellaneous:
    UI Language:  English
    Media Type:  Undetermined
    Total Hard Disk Space Available:  2394540 Mb
    Largest Free Hard Disk Block:  354851 Mb
    OS Install Date: Dec 31 1969
    Game Controller: None detected
    VR Headset: None detected

Workaround After days of researching how to remove the file share timeout in Windows and coming up with nothing, I've discovered that the easiest way to remove the hitch is by turning off the LanManWorkstation service. I believe this service is used as a client to connect to file shares. If the client is turned off, then the timeout countdown never occurs. Instead, all UNC path accesses immediately return an error thus removing the main cause for the slowdown.

Execute the following in an administrator prompt console. Please note, I do not take any responsibility for the damage this may cause to your machine:

net stop Workstation

Be sure to accept any on-screen prompts as they appear.

Other Notes I want to say thank you for fixing the save hitch issue recently. I'm hoping the fix can be applied relatively quickly due to its similar nature :D.

Related Issues

2798

kejoat commented 4 years ago

I checked my hl2 process with process monitor too today because I always have like more than a minute loading time for new areas/levels. The \MOD\ was certainly strange and so I found your github post here.

I did your steps to disable Workstation service (and could confirm it "working" by testing \mod path which immediately gave an error in explorer.exe), but it did not change the problem that hl2 is hanging for like ~1min7 on my system unfortunately.

Are there any other issues with hl2.exe that can result in such long loading times? I definitely see that during that time it basically just reads and writes around the saves folder because of the autosave ... but I also did not find a way to disable autosave (and marking autosave files as read-only did not help, maybe it's also the e.g. ep1_c17_00.hl1 files in that folder creating a problem ...)

I probably have to further check for issues :(

kejoat commented 4 years ago

Did another process monitor trace and it looks like the UNC access to \\MOD is still a problem: image

Though no idea how to solve that.