UE4.10 PhysX simulation randomly locked to 60Hz in optimized builds due to uninitialized variable

Hello,

I have found what I believe is a pretty serious bug in UE4.10 engine code that results in the PhysX simulate time randomly being locked to 60fps after a map travel, regardless of the actual game fps. This results in chaos in online multiplayer games as seen here, as the server + client will have wildly different physics simulation rates: Obliteracers - OBLITERATE YOUR FRIENDS ★ Obliteracers Early Look (Obliteracers Gameplay) - YouTube

In PhysScene.cpp, there is a static bool bInitializeConsoleVariable inside FPhysScene::FPhysScene(). It is statically set to true, and is used to set FrameTimeSmoothingFactor[PST_Sync] and FrameTimeSmoothingFactor[PST_Async]. After these are set, it becomes false. Obviously this is a problem, as the next time we run through FPhysScene construction (eg. on a map travel), FrameTimeSmoothingFactor[PST_Sync] and FrameTimeSmoothingFactor[PST_Async] are not set appropriately. Later on they’re clamped between 0 and 1. When 0, the frame time will just use the delta time as is. When 1, InitialAverageFrameRate is always used, which is 0.01666 (1/60), which is why the simulation becomes locked at 60fps sometimes.

My quick fix was to comment out the line: bInitializeConsoleVariable = false;

Cheers,

EDIT: I have just taken a look in Github and it appears this static initialization has been removed in the latest code (change 2775372 - Ori.Cohen), so this is no longer an issue. Cheers :slight_smile: -

Hello sds-,

Thank you for reporting this and for looking into it further. I’m glad to hear that this is no longer an issue. Please let us know if you find anything else and we’ll be happy to help.