Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by samuelmorais · Aug 19, 2016 at 01:25 PM · buildwebgl

WebGL cross-domain error when loading .mem file from remote

Hello,

I am trying to host the WebGL build files (.mem, .data and .js) in another server from my game's website and there is a problem with the browser's Cross-Domain restrictions.

I CAN load scripts from another server, because it is using Access-Control-Allow-Origin with '*' on the remote server. When I used Webgl prior to version 5.3, there was no problem, and I don't know why, since it also used XMLHttpRequest.

Error:

XMLHttpRequest cannot load http://remoteServerName.com/webgl/Release/webgl.mem. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://originServerName.com' is therefore not allowed access. The response had HTTP status code 404.

Line of code of UnityLoader.js that makes the XMLHttpRequest to load and decompress the "webgl.mem" file:

 function DecompressAndLoadFile(e,t,n){e+="gz";var o=new XMLHttpRequest;o.open("GET",e,!0)


Tha strange thing is that on later versions, when the loader was named fileloader.js and it didn't have the DecompressAndLoadFile function, it was working fine and I could load all the files from remote server without any problem.

My question is: how can I modify the above code so that it will load the .mem file with success?

IMPORTANT: I can't to host the .mem file at the same server, because of technical restrictions.

Thank you in advance.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by samuelmorais · Aug 20, 2016 at 08:45 PM

Now the .mem file is correctly loaded, but there is an error with .data file from remote or from the same server. I can run the build from my PC, but when I host it to Google App Engine / Google Cloud Storage, the errors appear. I have tried to host the .data file on another server that accepts gzip using Unity's .htaccess, but it does not work also.

Here is the URL of the project: http://6.animagolapp2.appspot.com/

Error:

loading webgl.data from cache UnityLoader.js:1 pre-main prep time: 3767 msModule.printErr @ UnityLoader.js:1doRun @ blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:39(anonymous function) @ blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:39

UnityLoader.js:1 Invoking error handler due to Uncaught TypeError: Cannot read property 'length' of null : Error at jsStackTrace (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:22715) at stackTrace (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:22898) at Object.handleFSError (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:74417) at _mmap (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:308189) at Array.Ans (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:32:280899) at Object.Fjs [as dynCall_iiiiiii] (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:32:254147) at invoke_iiiiiii (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:338421) at Sdq (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:31:186156) at Array.EAq (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:31:430097) at Object.gms [as dynCall_ii] (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:32:271915) blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:39 Uncaught TypeError: Cannot read property 'length' of null : Error at jsStackTrace (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:22715) at stackTrace (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:22898) at Object.handleFSError (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:74417) at _mmap (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:308189) at Array.Ans (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:32:280899) at Object.Fjs [as dynCall_iiiiiii] (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:32:254147) at invoke_iiiiiii (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:1:338421) at Sdq (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:31:186156) at Array.EAq (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:31:430097) at Object.gms [as dynCall_ii] (blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:32:271915)callMain @ blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:39doRun @ blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:39(anonymous function) @ blob:http://6.animagolapp2.appspot.com/9f1bd774-a299-4d37-8f16-38c9f1f91782:39

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

when build to webGL 0 Answers

WebGL URP Lit shader project settings graphics 0 Answers

Differences in Unity WebGL builds 2018.4->2020.3 0 Answers

How to profile a WebGL app using the unity profiler tool? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges