The OnSyncLoadPackage delegate is being triggered for cases where we do not synchronously load a package, such as when the package is already loaded or isn’t found. I can see why this might be a good idea, in theory - the delegate is triggered in cases where we’re attempting to load a package synchronously. But in practice, it can become very noisy depending on the load pattern of your game. I wonder if we could move where these delegates are triggered, or add another delegate that is triggered only when a synchronous load will happen.
The first place the delegate is triggered is just after the check for ShouldAlwaysLoadPackageAsync(), just below the comment that begins with “// This delegate is not thread-safe and the subscribers are mostly interested by sync loads”. Would it be better to move the triggering to be inside the check for “if (RequestID != INDEX_NONE)”, so that it’s only triggered if we’re going to call FlushAsyncLoading?
The second place the delegate is triggered is a little further down, just before the comment “// Set up a load context”. There are lots of ways to exit this function without actually loading a package, and I wonder if it would be better to move the triggering down inside the check for “if ((LoadFlags & DoNotLoadExportsFlags) == 0)”, just before the call to LoadAllObjects().
In my testing, this seems to eliminate all of the spurious triggers of the OnSyncLoadPackage delegate (most easily tested by logging a warning when the delegate is triggered). Do you see any problems with these changes? Is this something Epic could consider making on your side?