ZHMModSDK icon indicating copy to clipboard operation
ZHMModSDK copied to clipboard

Update NavKit and GitHub workflow

Open dbierek opened this issue 1 month ago • 0 comments

Description

This PR:

  • Fixes a game freeze that was occurring during a NavKit scene extract.
  • Updates the NavKit scene (nav.json) schema to version 1 for use with the upcoming NavKit 2.2.0.
    • Includes the roomName and roomFolderName fields to the NavKit scene extract (by @Joschuka )
  • Updates the github action workflow to:
    • On the main repo, build with the current settings:
      • Use ptlm-runner
      • Run on every master push
      • Run on every PR push
      • Run on every release
    • On forks, build with new settings:
      • Use windows-latest
      • Install rust-nightly
      • Run on every push to any branch
    • When a PR from a fork has a push, it will be built on the main repo and the fork
  • This PR also updates the mutex lock for the DestroyEntityInternal loop to use RAII.

Freeze

Steps to reproduce the freeze:

  1. Launch Hitman and load a large scene, for instance the Marrakesh or Paris story missions
  2. Open the SDK console so the game remains unpaused
  3. Switch to NavKit 2.0.1 or 2.1.0
  4. Run the Extract scene from game command
  5. After a certain amount of entities are sent the game freezes

I was able to consistently cause the game to freeze following the above steps.

Explanation of the issue

While investigating I added logs and determined the freeze was happening in the IsPropertyValueTrue function, just before calling AllocateAligned.

IsExcludedFromNavMeshExport: Checking entity f4e10d0539ff565c
... checking property index 0 with ID 56103966
... checking property index 1 with ID 4d991c38
... checking property index 2 with ID 113d1a0b
... checking property index 3 with ID d0d7c06c
... ... inside IsPropertyValueTrue, about to call AllocateAligned for property type 'bool'

Checking with Gemini code assist provided the following:

The call to (*Globals::MemoryManager)->m_pNormalAllocator->AllocateAligned(...) is blocking indefinitely. Your server thread is trying to acquire a lock on the game's memory allocator, but the main game thread is holding that lock while it's running the game simulation. The server thread is now frozen, waiting for a resource that won't be released.

Explanation of the fix

This PR prevents the deadlock by only using the game's memory allocator within a game thread (in OnFrameUpdate), and sending the data across the socket using the EditorServer thread.

Verification

I tested this by following the same steps as above on both Marrakesh and Paris, and it did not freeze the game, and instead the NavKit scene extract worked normally.

Scene Schema update

Changes schema to NavKit scene schema version 1. Example:

{
	"version": 1,
	"meshes": [
		{
			"alocHash": "00D40317366D56BD",
			"primHash": "000C0FDBE7247CE9",
			"entity": {
				"id": "80b9bfc4e5d50a1a",
				"name": "Bunker_Electrical_Wall_A_00",
				"tblu": "008A26DAC4733ED8",
				"position": {
					"x": 1.7723740339279175,
					"y": 18.03261947631836,
					"z": 4.998621940612793
				},
				"rotation": {
					"x": 0.7071067690849304,
					"y": 0.0,
					"z": 0.0,
					"w": 0.7071067690849304
				},
				"scale": {
					"type": "SVector3",
					"data": {
						"x": 1.0,
						"y": 1.0,
						"z": 1.0
					}
				}
			}
		}
	],
	"pfBoxes": [
		{
			"id": "db89f6aa5c645cac",
			"name": "PFBox",
			"tblu": "002EA1AFC127657D",
			"position": {
				"x": 96.9665,
				"y": -34.2811,
				"z": 53.1982
			},
			"rotation": {
				"x": 0,
				"y": 0,
				"z": 0,
				"w": 1
			},
			"type": {
				"type": "EPathFinderBoxType",
				"data": "PFBT_INCLUDE_MESH_COLLISION"
			},
			"scale": {
				"type": "SVector3",
				"data": {
					"x": 200,
					"y": 340.06,
					"z": 46.1232
				}
			}
		},
		{
			"id": "a6bfe4d26ba01ff9",
			"position": {
				"x": 24.8751163482666,
				"y": -23.84190559387207,
				"z": 0.07189199328422546
			},
			"rotation": {
				"x": 0.0,
				"y": 0.0,
				"z": 0.0,
				"w": 1.0
			},
			"type": {
				"type": "EPathFinderBoxType",
				"data": "PFBT_EXCLUDE_MESH_COLLISION"
			},
			"scale": {
				"type": "SVector3",
				"data": {
					"x": 3.8745100498199463,
					"y": 5.517429828643799,
					"z": 1.0
				}
			}
		}
	],
	"pfSeedPoints": [
		{
			"id": "2e81dc1b8a9dda60",
			"position": {
				"x": 1.1165820360183716,
				"y": 60.05158996582031,
				"z": 6.070188999176025
			},
			"rotation": {
				"x": 0.0,
				"y": 0.0,
				"z": 0.0,
				"w": 1.0
			}
		}
	]
}

dbierek avatar Dec 03 '25 09:12 dbierek