LoadPackageAsync always fails if file string not correctly formated

I was looking into loading asset elements using LoadPackageAsync and get it crashed every time I passed a filename even if this file exists. If I the log file I have the corresponding massage : “LoadPackageAsync failed to begin to load a package because the supplied package name was neither a valid long package name nor a filename of a map within a content folder: ’ '”.

When I investigating why this problem happens, I think I discover where the problem comes from. In the file AsyncLoading.cpp, in the function int32 LoadPackageAsync(const FString& InName, const FGuid* InGuid /*= nullptr*/, const TCHAR* InPackageToLoadFrom /*= nullptr*/, FLoadPackageAsyncDelegate InCompletionDelegate /*= FLoadPackageAsyncDelegate()*/, EPackageFlags InPackageFlags /*= PKG_None*/, int32 InPIEInstanceID /*= INDEX_NONE*/, uint32 InPackagePriority /*= 0*/) the line if (!(FPackageName::IsPackageFilename(InName) && FPackageName::TryConvertFilenameToLongPackageName(PackageName, PackageName))) always failed because PackageName is never initialised and this error will never recover. I don’t know if this is actually the right behaviour but its strange to make some test that always fails.

I set up a workaround so it don’t have to call the previous test.

Hey RouxNicolas-

Could you provide the callstack and log files from the crash? This may involve causing the crash to occur again to generate the necessary files. Additionally, would it be possible to provide a small sample project with this issue and/or list the steps that lead to the crash so that I can test on my machine?

As request you will find attach
the appcrash and a simple test project. In addition you have to add a package obtained when you package the project in the directory /content/pak/ to make it work. It do not matter what is in the package.

Forgot to save Test levelbefore sending it. It only contains a Myimportpakfile actor. To make it run/crashe, once it is started, only press the num 2 key.

Hey RouxNicolas-

When I open the project and press 2 there is an error that the file ExternalContent.pak does not exists. When I opened the Pak folder I noticed it was empty. Is there a file I need to create/add to the Pak folder? If it’s possible to reproduce the crash in a new project, can you list the steps that cause the crash to occur?

The ExternalContent is the package obtained when cooking the game or running UnrealPak.exe. As it is too big I can’t attach it to the response. To change pak name or location you can make it in AImportPakFile::RunLoad().

Just wanted to chime in. I am having a similar issue with the 4.11 p8. Nicholas can you post details on your workaround? I am a little lost where to go next.

The problem (for me) was that the test FPackageName::IsValidLongPackageName() always fail because the file has format that is incompatbible ( ex(" ../../../../../../Users/[UserName]/Documents/Unreal Projects/[ProjectName]/Content/Floor_400x400.uasset), because it contains ‘.’ and the path isn’t one of the path the engine is looking for. So to solve it I add this line of code before calling the RequestAsyncLoad of the streamable manage :

if(AssetName.RemoveFromStart("../../../../../../Users/[UserName]/Documents/Unreal Projects/[ProjectName]/Content"))
{
	if (AssetName.RemoveFromEnd(".uasset"))
	{
		FString Name = AssetName;
		Name.RemoveFromStart("/");
		StreamedAssets.Add("/Game" + AssetN ame);
	}
}

if the UnrealProject directory is in your document directory. [ProjectName] is the name of your project.
If you are looking for engine file replace ../../../../../../Users/[UserName]/Documents/Unreal Projects/[ProjectName]/Content with ../../../Engine/Content/StreamProject/Content and “/Game” by “/Engine”.
Hope it helps

Hey RouxNicolas-

I apologize for the delayed response and I’m glad you were able to find a solution to the issue. Unfortunately I am not familiar with using LoadPackageAsync and have not been able to setup a reproduction case for investigation. You supplied a sample project when I found does not package successfully but I don’t believe this is what you’re referring to. Can you provide any further information that would help me understand exactly what you’re attempting to do and what is failing for you?

Indeed there is a problem when packaging a file.
If you want to create from a new project here is the step :

  • Create a new c++ project. ;
  • Import code from AssetStreamer, ImportPakFile and Singleton";link text
  • In the Project.Build.cs add in public dependency the string “PakFile”, “StreamingFile”;link text
  • In the project settings>General settings seleect the Singleton class for Game Singleton Class;
  • Create a blueprint class from the ImportPakFile and place the actor in the world;
  • Create a package and move it to your project directory/Paks/ExternalContent (path to create) [Optoinally] To change the loading path, you need to change it in the ImportPakFile in the function RunLoad(). It should take each package in the directory.
  • To run the crash you have to run th RunLoad() function

You will find attached the c++ and cs file defined (there are the same as in the testlevel.

I try to load a dynamically a 3D object. The problem is that I can’t load in game FBX file and because the file loaded are numerous and very big. In addition as the game will evolve in time, we don’t want to repackage each time the game, we choose to load the package file generated by the UnrealPak.exe. Maybe there is another solution but I am not aware of this.

Hello RouxNicolas,

I was able to reproduce the crash that you’re getting, but I wanted to try to clarify some things before reporting this issue, so that I’m sure that we have the correct information.

From reading over the previous comments, it seems as though your issue was that the output from FPackageName::IsValidLongPackageName() is not able to be used with RequestAsyncLoad due to the format that it’s in. Trying to do this results in this crash, correct? If I’ve missed anything, please let me know and I’ll add it to the report. Thank you for your cooperation in this matter as well.

Hello ,

Maybe I misunderstand your reply but the function FPackageName::IsValidLongPackageName() itself won’t crash. As it is use for testing the package name, if the function return false, a second set of test will be done. It they also fails then there is a call to a UE_LOG(Fatal) which crash the game.
The reason the test fails are due to the filename is empty. That’s why I sugest to remove the first “…/…” in my answer

Thank you for that clarification, but I’m not quite sure I understand what you mean. If you’re removing that section, yet the “filename is empty” then what are you removing it from? Also, is this string (I.E. …/…/…/…/…/…/Users/[UserName]/Documents/Unreal Projects/[ProjectName]/Content) hardcoded or something that you’re getting returned from a function? Is it that passing a string such as that into the RequestAsyncLoad function ultimately initiates the crash?

The program goal is to load elements contained from a pakage generated by Unreal Engine. After mounting it I look for the files containing it and try, if it is a uasset, to load it (function FAssetStreamer::StreamPackage). The uasset name and path is given when I call the function on IterateDirectoryRecursively (function FindAllPakFiles). Dependgin on the the mounting path the path may be different but in my case it is something like …/…/…/…/…/…/Users/[UserName]/Documents/Unreal Projects/[ProjectName]/Content. When I call StreamableManager::RequestAsyncLoad with this path the program crash and when I investigate further I get a empty string before calling FPackageName::IsValidLongPackageName(). That is why I suggest to remove …/… because without it I get a valid package name and no crash

弄了10天终于成功了。。。。。:)

通常pak是很容易加载成功的,而异步读取资源是否成功取决于你读取的路径是否正确。把那些…/…/…/…全部删掉,之后就可以在资源注册表通过各种方法使用这些资源了。have good day :)

Thank you for the help understanding your issue, RouxNicolas. I’ve placed a bug in for the issue under the bug number UE-29849. I’ll be tracking it and I’ll let you know whenever there are any updates to the issue or if we need any more information from you.

Have a nice day!

弄了两天终于把路径试对了,但是异步读取资源的时候提示
LogLinker:Warning: The file ‘…/…/…/LoadTest/Content/Content/ArchVis/Textures/T_Wood_S.uasset’ contains unrecognizable data, check that it is of the expected type.
难道是我pak文件打包设置有问题

请把你的代码贴上来,通常PAK打包是否成功是可以检查的,在控制台输入命令使用UnrealPak.exe进行检查:cd C:\Program Files\Epic Games\4.9\Engine\Binaries\Win64
UnrealPak.exe C:\New2.pak -List
pause
查看名称是否正确。
按照我的经验你的问题并不只是路径的问题

uasset需要进行COOK才能进行异步加载,如果你确定自己的资源已经烘焙过了,那么找出问题就要看你的代码了