Search Unity

Question WebGL - Uncaught RangeError ?

Discussion in 'Editor & General Support' started by sulapse9, Mar 30, 2020.

  1. sulapse9

    sulapse9

    Joined:
    Oct 2, 2018
    Posts:
    1
    Hey,
    I've been googling like crazy but can't seem to find any related problems in Unity.

    I've put together a small WebGL test game, and uploaded this to my website.
    However, when I load the page I get a javascript error saying
    " An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was: Uncaught RangeError: Offset is outside the bounds of the DataView"

    And in the JS console I get:

    I could only assume it's a host-related issue, as it works just fine when running locally using XAMPP.
    Sidenote: The web host I'm using is hostinger.
     
    patrik-org likes this.
  2. patrik-org

    patrik-org

    Joined:
    Sep 10, 2012
    Posts:
    100
    It had to do with MIME mappings missing for me, I could register them in Startup.cs (.NET Core website)

    var provider = new FileExtensionContentTypeProvider();
    provider.Mappings.Remove(".unityweb");
    provider.Mappings.Add(".unityweb", "application/octet-stream");
    provider.Mappings.Remove(".data");
    provider.Mappings.Add(".data", "application/octet-stream");
    provider.Mappings.Remove(".wasm");
    provider.Mappings.Add(".wasm", "application/wasm");
    provider.Mappings.Remove(".symbols.json");
    provider.Mappings.Add(".symbols.json", "application/octet-stream");
    app.UseStaticFiles(new StaticFileOptions
    {
    ContentTypeProvider = provider
    });