x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Html build packaging broken for shipping builds

The files for the packaged html builds are being named incorrectly when they're compressed. For example jsgz instead of js.gz. It's also not using the correct template, it uses templateX instead of the template for the compressed files. I've tried changing everything manually, but somewhere it calls for the data file and I can't find where to change it to the compressed type.

Product Version: UE 4.11
Tags:
more ▼

asked May 06 '16 at 08:47 PM in Bug Reports

avatar image

Feuern_D
282 8 11 129

avatar image Feuern_D May 06 '16 at 10:15 PM

To clarify further this happens in source builds and the regular releases. Both are in 4.11.2. I used Tappy Chicken to test it out also. Tappy chicken packages fine and has the correct compressed files in 4.10.4 and so does my project, but both generate the same wrongly named files, and use the wrong template for the compressed files. Any idea on how to fix this on my end would be greatly appreciated though.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Is there some option in the UE4 editor to switch to utilizing the precompressed files? If so, I haven't used that, but I do routinely host precompressed files of UE4 exports. What I do is just export as usual, and then modify the .html file as follows.

First, find the definition of Module.locateFile() in the generated .html file:

 var Module = {
   ...
   // file location. 
   locateFile : function (name){ 
     return name;
   },
   ...
 };
 

and edit that to the form

 var Module = {
   ...
   // file location. 
   locateFile : function (name){ 
     var isAbsoluteUrl = name.indexOf('://') != -1;
     // Fetch gzipped content if via a CDN, but when via file://, load up the noncompressed files.
     if ((isAbsoluteUrl && name.indexOf('file://') == -1) || (!isAbsoluteUrl && location.protocol.indexOf('file') == -1)) return name + 'gz';
     return name;
   },
   ...
 };
 

Then find all references to the URLs in the html page, and replace them to route through the Module.locateFile function. For example:

 ...
 
 $.ajax({
   url : "ShooterGame.js.symbols",
 
 ...
 
 var promises = [
   'Utility.js',
   'ShooterGame.data.js',
   'ShooterGame.js'
 ].map(download);
 
 ...
 
 

becomes

 ...
 
 $.ajax({
   url : Module.locateFile("ShooterGame.js.symbols"),
 
 ...
 
 var promises = [
   Module.locateFile('Utility.js'),
   Module.locateFile('ShooterGame.data.js'),
   Module.locateFile('ShooterGame.js')
 ].map(download);
 
 ...
 

After that, if the page is loaded via a http:// or https:// URL, it will fetch the .jsgz, .datagz and .symbolsgz files. However if the files are uploaded to a CDN, e.g. S3, it won't work by default, since the web servers will incorrectly autodetect the mime type the content. For it to work, the CDN will need to be configured to add the following header rules for the gz-ending files:

.jsgz files need

 Content-Type: application/x-javascript
 Content-Encoding: gzip

and .datagz, .symbolsgz and .memgz files need

 Content-Type: application/octet-stream
 Content-Encoding: gzip

If you'd prefer using suffixes .js.gz instead of .jsgz and so on, that works as well, as long as the above headers are configured for the web server, and Module.locateFile() is set to append ".gz" suffix instead of only the "gz" suffix.

You'll see that the above changes don't change the loading of the .data and the .mem files anywhere, but it seems to magically work for those files as well. The reason for that is that the Module.locateFile() is actually an Emscripten runtime function that the Emscripten loader calls for these files when it is loading them up, see Module.locateFile documentation and occurrences of Module.locateFile in Emscripten runtime.

This setup works for UE 4.11.2, I think 4.10 and older generated a different looking .html output, so for those the changes would be somewhat different.

If there is some UE4 provided checkbox for enabling compression, I wasn't aware of that, which is why I developed this manual configuration :| Of course any bugs on that method should be addressed by the developers.

more ▼

answered May 07 '16 at 09:55 AM

avatar image

juj
1.2k 15 4 17

avatar image Feuern_D May 07 '16 at 05:37 PM

You rock, I modified the HtmlX.template file with the your code and it worked perfectly. Thank you very much. I know next to nothing about emscripten or javascript for that matter, so that presents a problem when dealing with HTML5 development through UE4. Now if I could only get UE4 to not upload uncompressed files to the S3, I would be in good shape for automating this process. Anyways, thanks again.

avatar image Feuern_D May 07 '16 at 06:22 PM

After further inspection, the code forces a load from the compressed files regardless of whether or not it's on the S3 or local. I don't need it load uncompressed files though, just letting you know.

avatar image Andyram May 07 '16 at 08:08 PM

Hi feurern, once i did the changes as mentioned above in ".html" file. I tried refreshing the browser, although the load is faster but it is throwing reference error _gclearstencil. any idea about this ??

avatar image Feuern_D May 07 '16 at 08:55 PM

What html file did you put it in? Your project file or the HTMLX.template?

avatar image Andyram May 08 '16 at 01:52 AM

The output file in the folder, the file which we get once after shipping the project to HTML5. It is the only html file in the folder along with data.jsgz , data.gz, house3.data , utility and others. btw is it the same HTMLX.template ?

avatar image Feuern_D May 28 '16 at 11:15 PM

Apologies for falling off here and not responding. I stopped working on the html build once I got this working. Too many issues to make it viable at the moment, specifically the massive file sizes and the inability for it to work on mobile browsers. Which I assume are both related. I believe the clearstencil error is related to the fact that HTML5 builds don't support custom depth stencils.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question