Search Unity

Bug WebGL

Discussion in 'Editor & General Support' started by xtdiwd, Jan 12, 2021.

  1. xtdiwd

    xtdiwd

    Joined:
    Jul 25, 2020
    Posts:
    135
    Trying to compile for WebGL I got an import error for ogg files.
    When the compilation finished, none of my browsers could run the game because it is not supported: Explorer and Firefox. Edge instead says "It seems your browser does not support running Unity WebGL content from file:// urls. Please upload it to an http server, or try a different browser.".
    I also suggest to check the working on Android browsers!

    I'm sorry, why in the tag field I can write what I want, if then I am forced to choose between those proposed?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    If your web browser doesn't support opening your WebGL build directly from the filesystem, you have a few options:
    • Get a different web browser that can, or figure out how to configure your browser to allow it
    • Host your WebGL build on a real web server (IIS for windows, nginx, Python http.server, etc...)
    • Use this free Unity package to deploy your webGL build directly to Unity Connect: https://docs.unity3d.com/Packages/com.unity.connect.share@1.2/manual/index.html (note Unity connect is going away next month)
     
  3. xtdiwd

    xtdiwd

    Joined:
    Jul 25, 2020
    Posts:
    135
    Thanks for the reply, but I don't think it can work:
    1) I can't force my users to follow a procedure that I myself find complicated to configure the browser in order to play the game. Already some users might not like having to install a particular browser.
    2) My idea is to compile for WebGL but run it locally, so that users who don't use Windows or Android can still use my games.
    3) Obviously

    I think it's something that should be solved in the next Unity LTS.

    I use WebGL to simplify for my users, not to complicate.
     
    Last edited: Jan 13, 2021
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    The problem you're running into is a limitation of your web browser, not Unity. There's nothing Unity can do about it.

    It's a well-meaning idea, but as you can see, WebGL is meant to be hosted on a website. It is not intended to be distributed around as a portable game package.

    Good Luck.
     
    Last edited: Jan 13, 2021
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I think you misunderstood @PraetorBlue 's post. When you actually deploy your game it will be on some interwebs server somewhere, so issues with a browser running the game locally off your HDD instead of on a proper web server won't exist. So you won't need to give users a complicated set of steps to follow. Those steps to follow are just for you to test your game locally.

    If you want to skip all that, just do a proper publishing to your own web server, so you're testing it like any other user would. That's a better idea from a QA perspective anyways, since it is as close as you can get to the user experience. Just it probably will cost you money to rent the server when you probably don't want to spend it (or you'd have done it already).

    For #2 though, please note that mobile devices are not supported by Unity's WebGL builds at this time. Might work, might not. But you should go the app route for mobile devices.
     
    PraetorBlue likes this.
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Oh I should have read the entire thread first :facepalm:

    Don't do this. The reason it isn't working for you this way isn't caused by Unity. Browser makers have been putting this limitation in because of potential security exploits for allowing local file access. You'd have to complain to google or whoever makes your specific browser, but you'll be ignored. This was done some years ago by many (most?) browser providers. I think it happened around the same time a variety of browser add on's features were nuked in the name of security. Same time Unity needed to move to WebGL cause Browsers stopped supporting Unity WebPlayer.