[HTML5] Changing the UE4Game.js.mem location results in an "Corrupted index offset in pak file." error


I’ve been trying to get HTML5 UE4 set up so files can be in different directories on the web server and still load. I was able to get the .data file to load by adding “filePackagePrefixURL: ‘http://localhost:3000/games/’” to the emscripten Module initializer. However, trying to get the UE4Game.js.mem file to load from another directory by adding:

locateFile: (function(name){return"http://localhost:3000/javascripts/engines/4.8/UE4Game-HTML5-Shipping.js.mem"})

results in the error:

LowLevelFatalError [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.8\Engine\Source\Runtime\PakFile\Private\IPlatformFilePak.cpp] [Line: 324]
Corrupted index offset in pak file.

It looks like the locateFile entry does work because the console says “http://localhost:3000/javascripts/engines/4.8/UE4Game-HTML5-Shipping.js.mem downloaded”, but it still doesn’t run due to the error.

I know one workaround could be to have it build the .mem into the javascript, but that will hurt load times and possibly run into compatibility issues in javascript engines that can’t support large arrays. Is there any way to solve this problem so locateFile doesn’t cause this pak file error?


locateFile is used for loading multiple things, not just the mem file…

locateFile: (function(name){return"http://localhost:3000/javascripts/engines/4.8/UE4Game-HTML5-Shipping.js.mem"}) - you are returning the mem file always when it might trying to locate something else. ( e.g the data file )

Its basically used for adding prefixes or suffixes to the name, if needed.

you would want to do something like

 // pseudo code 
  locateFile : function (name){ 

   if (name == "UE4Game-HTML5-Shipping.js.mem" )
        return "engines/4.8."  + name ;
  return name; 


Actually, Ankitkk’s answer will result in the same error message (or at least it did for me). What it should be is

// pseudo code
	locateFile : function (name){
	      return '/engines/4.8/'  + name  ;