It's possible to track invalid file reads happening in the game during run-time. The error message 'Invalid File Access' means reading or trying to open files from a thread which is not the streaming thread. These file access operations can cause quite severe stalls.
Currently the file access tracking only logs access from the main and render thread.
The following cvars will trigger different option to track the file access.
- Access is logged to game.log.
- Generates a perfHUD warning.
- Written on screen in red in upper left corner of the screen.
- Stall for 3 secs in non-release builds.
- File access, along with callstack is logged and saved to a file on the console in the sub-directory FileAccess (currently for Xbox 360 only).
- Also all the functionality of 1.
- Creates a popup dialog (for PC and Xbox 360, debugbreak on PS3) when a file is accessed, you can choose to break into the debugger or continue.
Where is invalid access defined
The points which define when file access is invalid are set using ICryPak::DisableRuntimeFileAccess with true or false. These points may need to be tweaked for single player and multiplayer.
It is possible to add some exceptions to the file access tracking, so you ignore certain files (e.g game.log).
Simply create an instance of CDebugAllowFileAccess in the scope which accesses the file.
Resolving file access callstacks
The files collected using pak_LogInvalidFileAccess 2 will need their callstacks resolving, to this we need the .pdb/s from the build, the XenonStackParse tool, and the helper script ProcessFileAccess.py
The tools can found in the XenonStackParse folder of the Tools directory.
The directory structure for running ProcessFileAccess.py should be as follows:
--> FileAccessLogs (this dir should contain the .pdbs)
------> Processed (outut from XenonStackParse)
Run ProcessFileAccess.py from the FileAccessLogs dir (XenonStackParse uses the working directory to search for the .pdb files). This will create a direction called processed, which will have a file containing the resolved callstack for each of the logged files.