Reputation: 527
I'm trying to use webassembly streaming feature but it does not work.
I did follow the unity docs instruction of Server configuration for WebAssembly streaming.
https://docs.unity3d.com/2019.3/Documentation/Manual/Webgl-Server-configuration-for-WebAssembly-streaming.html
I'm using Unity 2019.2.20f1
In Unity player settings, I set the compression format as gzip and enabled WebAssembly streaming.
I added .htaccess file into the Build folder.
following is the contents of the .htaccess file
<IfModule mod_mime.c>
AddEncoding gzip .unityweb
AddType application/wasm .wasm
AddEncoding gzip .wasm
AddOutputFilterByType DEFLATE application/wasm
</IfModule>
and I also added
application/wasm wasm
to /etc/mime.type
But I'm getting this Error.
wasm streaming compile failed: CompileError: WebAssembly.instantiateStreaming(): expected magic word 00 61 73 6d, found 1f 8b 08 18 @+0
I did restart the service after setting up the needed modifications.
my webgl builds work perfectly without webassembly streaming feature.
Is there anyone who knows about this problem and what i'm doing wrong?
Upvotes: 1
Views: 11243
Reputation: 527
For those who have the same problem, I solved this one.
first you need to enable the AllowOverride in httpd.conf file to use .htaccess file.
in my case it's located at /etc/httpd/conf
and open the httpd.conf file using vi httpd.conf
command
and find .htaccess using /.htaccess
command
there will be <Directory "/var/www">
and <Directory "/var/www/html">
and you will see for both of them AllowOverrides are set as None.
You need to change those to All.
simply hit i
and you will be in insert mode, change AllowOverride None
to AllowOverride All
make sure you change both /var/www
and /var/www/html
When you're done, hit ESC
and type :wq
to save the modification and exit.
following .htaccess file does not work.
<IfModule mod_mime.c>
AddEncoding gzip .unityweb
AddType application/wasm .wasm
AddEncoding gzip .wasm
AddOutputFilterByType DEFLATE application/wasm
</IfModule>
change .htaccess file as following will do the job.
Options +FollowSymLinks
RewriteEngine on
<Files "*.wasm">
AddType application/wasm .wasm
AddEncoding gzip wasm
</Files>
<Files "*.unityweb">
AddEncoding gzip unityweb
</Files>
If you're using brotli, change gzip
to br
Lastly, you have to restart httpd service by using service httpd restart
command.
Boom! It works now.
And about the load speed i mean, sure it's faster than the non-WebAssembly Streaming.
but my project has total of 50mb of data size and the difference was minimal.
So if you're project has big amount of data to load, you should give it a try.
but if it's not that big, don't expect sth dramatic here.
Upvotes: 4