Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Unity WebGL build only loads for the first time and doesn't load after that.

Discussion in 'Web' started by alexandroid1990, May 7, 2023.

  1. alexandroid1990

    alexandroid1990

    Joined:
    Apr 7, 2023
    Posts:
    13
    Even after re-uploading to the server, it only loads for the first time and doesn't load after that.
    It stops loading when pressing the refresh button or navigating to another page and then returning.
    Clearing the cache didn't make a difference. unityquestion (2).png The Chrome Developer Tools console displays the messages 'Failed to download file Build/xxx.data' and 'Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'buffer')'
     
  2. kyousuke0916

    kyousuke0916

    Joined:
    Apr 9, 2020
    Posts:
    4
    Yesterday, I suddenly ran into a similar problem, my Unity version is 2021.3.0f1. The first time I can go in normally, but the second time I get stuck loading the screen, it seems to be related to the cache. But this only seems to happen on Android, iOS doesn't get stuck, And my game hasn't been updated for 4 months, it was yesterday that it suddenly got stuck.
     
  3. AdamandEveStudios

    AdamandEveStudios

    Joined:
    Apr 19, 2022
    Posts:
    35
    Relaunch it in incognito mode and always "Name Files As Hashes" enabled
     
  4. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    601
    I have see several games like https://warmerise.com/ using the version 2021.1.x => 2021.3.14f1 that got the same issue.
    The first load work perfect but the second load fail with the error :
    For me it fail only with chrome but work perfect in firefox.
    Maybe it's brotli issue because an other game that use the same version but still in gzip work in chrome.
    Point to check for me is the compression build used, stripping and maybe if you have made a change at the unity cache system in the editor folder.
     
    DavidWeng likes this.
  5. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    601
    This will not solve the issue and "normal" player will never do that by themself.
    The point here is too find the issue and to solve it in order to give the best experience to the players.
     
    LilGames and DavidWeng like this.
  6. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    601
    Point to check for me is the compression build used, stripping and maybe if you have made a change at the unity cache system in the editor folder.
     
  7. kyousuke0916

    kyousuke0916

    Joined:
    Apr 9, 2020
    Posts:
    4
    We have several projects using Unity 2021.3.0f1, and suddenly on 2023/5/7 all of them are having problems together,
    The first load will enter the game normally, but after the second load, it will get stuck on the load screen.

    The problem we are experiencing is that it is only happening with Android. iOS is currently working fine to enter the game.

    We have not updated these projects for several months and they will be available until 2023/5/7.
    This is my error message:

    [UnityCache] Failed to load

    Code (CSharp):
    1. 'https://xxxxxxxx/PROJECT_NAME/Build/867c7ba58f030ba3290579794fddbbbc.data.unityweb' from indexedDB cache due to the error: TypeError: Cannot read properties of null (reading 'getReader') -- From line 1 of https://xxxxxxxx/PROJECT_NAME/Build/Web.loader.js
    2. Failed to download file Build/867c7ba58f030ba3290579794fddbbbc.data.unityweb -- From line 1 of https://xxxxxxxx/PROJECT_NAME/Build/Web.loader.js
    I was able to reproduce the problem by opening an empty project with Unity 2021.3.0f1 after just testing it.
    As long as Data Caching is checked, Android gets stuck on the load screen regardless of whether I have to gzip compression or not.

    If I upgrade Unity to 2021.3.20f1 I can get Android back to normal.
    But it's worrying, will Unity 2021.3.20f1 suddenly break down one day?
    So we want to know what the root cause of the problem is, so that the next time this temporary major problem does not occur again.


    I have attached my test project configuration and test project below.
    截圖 2023-05-08 下午5.47.06.png 截圖 2023-05-08 下午5.47.22.png 截圖 2023-05-08 下午5.47.31.png
     

    Attached Files:

  8. roka

    roka

    Joined:
    Sep 12, 2010
    Posts:
    601
    Yeah it's weird that it happen like that when everything was working fine during several months.

    This game (https://warmerise.com/) was working fine also and one day, without any game update this problem have started.
    It's maybe related to a chrome update because it started to not work after i updated my google chrome, firefox,operagx is not afected but brave is affected too and it use chromium too :).

    My games (https://www.gaming-style.com/) use Unity 2019.4.38f1 with the old cache system and they are not affected. It's why i'm always scared to update my game to a new unity version.
    I have made a post already about a broken compatibility between the old and new system here https://forum.unity.com/threads/web...n-recent-unity-versions.1343537/#post-8483339
     
    DavidWeng likes this.
  9. HomelessShrimps

    HomelessShrimps

    Joined:
    Nov 3, 2012
    Posts:
    64
    I have the same issue. All of my previously working 2021.3.5f1 WebGL builds stopped working now. Today they loaded once and worked just fine, but not the second or third time.
     
  10. maxbaranuk

    maxbaranuk

    Joined:
    Aug 5, 2015
    Posts:
    1
    It looks like the browser's problem. We experienced the same issue in Chrome and Edge (on 112 and 113). But the latest Chrome update (113.0.5672.92) fixed the problem. On Edge the issue is still present, but I guess we should wait for the fix on their side.
     
    Last edited: May 10, 2023
    DavidWeng likes this.
  11. HomelessShrimps

    HomelessShrimps

    Joined:
    Nov 3, 2012
    Posts:
    64
    Most of the time we can't just hope that the end-user has the latest Chrome update when they visit our game. The build has to be stable across as many versions of browsers and versions.

    Downgrading my Unity project to 2020.3.29f and rebuilding the game fixed the problem for me.

    That gives me the idea, that this problem could also be fixed on Unity side. We don't need to wait for browser fixes.
     
  12. kyousuke0916

    kyousuke0916

    Joined:
    Apr 9, 2020
    Posts:
    4
    I upgraded to Unity 2021.3.20f1 to fix this problem, but I'm worried that this version will have this problem again someday.