WebGL build - Unknown error occurred while loading 'sharedassets1.assets'

hello! recently ran into a roadblock trying to build a new game for the first time and would appreciate some help.

ive built a few WebGL games in the past, in unity 2019.4, and had no problems. however, a plugin im using required me to upgrade to 2021.3 for my current game, which i did. i have no problems running my game in the editor, but when i build it, i run into the following issue:

  1. the game loads past the splash screen and into the main menu scene. the main menu works fine.
  2. as soon as the “new game” option is selected and the game scene is loaded, the game hangs. the browser inspector shows thousands of lines of "Unknown error occurred while loading ‘sharedassets1.assets’ are being generated, it got up to over 80000 in a few seconds and lagged the build-and-run browser tab so much i had to close it (see image)

i also tried building just the game scene without the main menu, and i immediately run into the same errors after the splash screen.

here is the breakdown of the assets from the build report. i know the textures are ridiculous; i havent optimized anything yet. but could that be related somehow?

Build Report
Uncompressed usage by category (Percentages based on user generated assets only):
Textures               12.6 gb	 99.4% 
Meshes                 0.0 kb	 0.0% 
Animations             1.0 mb	 0.0% 
Sounds                 71.3 mb	 0.5% 
Shaders                43.2 kb	 0.0% 
Other Assets           8.4 mb	 0.1% 
Levels                 0.0 kb	 0.0% 
Scripts                132.4 kb	 0.0% 
Included DLLs          0.0 kb	 0.0% 
File headers           113.9 kb	 0.0% 
Total User Assets      12.7 gb	 100.0% 
Complete build size    194.9 mb

i have fiddled with various compression settings for the build to no avail, but i really have no idea what im doing or how to start approaching this problem. if anyone can point me in the right direction, id really appreciate it ^^

are you sure you uploaded the asset bundle?

oh, im not sure what that is? how would i check that, and/or include it?

Not a master of asset bundles, but the reason being is that the sharedassets1 is not a normal name for anything on a webgl build, but sounds more like a default name for an asset bundle.

Im sure theres a bunch of videos on youtube, but theres a folder of bundles you would upload if this is the case

:open_mouth:

Even assuming these texture are compressed … perhaps you may be pushing WebGL too hard? You have a 2 GB memory limit currently (in 2021.3 for sure), plus the user’s loading time.

Perhaps it’s simply choking on the size of the assets is what I’m saying.

Also since you upgraded anyway, why not try 2022 and Unity 6? The WebGL platform continuous to see major updates with each iteration becoming slimmer and faster to load by default. Plus with 6 you can disable the splashscreen logo.

oh, interesting, i havent changed the way i handle assets compared to the other games i built tho, its all just image/sound files/scripts in folders. the only differences with assets i can think of are:

a) this is my first time using asset packs, i purchased some sfx from the unity store and imported into the project. but the main menu is working fine…
b) i purchased the TextAnimator package to handle my dialogue boxes. this isnt present in the main menu and DOES run every frame afaik, so it could possibly be the issue? i will try adding it to the main menu when i get home and see if that introduces the error there, but how would i go about fixing it if its an external package that has assets not being included?
c) i manually added the softmask plugin from github into my packages folder, but found it didnt do what i wanted, so i deleted it, but perhaps didnt do it properly?

additionally, i was able to find a similarly named file in “Library > PlayerDataCache > WebGL > Data”, there is sharedassets0.resource and sharedassets1.resource, which i assume corresponds to each scene (since there was only sharedassets0 when i built the game without the main menu, and the error occured on that file instead). but i have no idea how this file is being created…

thanks so much for helping ^^

its possible! its a game with hd2d chara sprites (think ace attorney), and im at the stage where every frame takes the full screen just due to not having figured out how to properly set origins if i were to use spritesheets :sweat_smile: thats a separate issue im planning on asking about after i get a build to work tho ^^

in terms of updating tho, ive been working on this project on and off for a good few years and would rather not update in the middle of development, esp since i think some of my packages arent supported on the latest version. webgl is just for a demo version, so im not too concerned with making it perfect, but maybe on the next game!

well, i managed to swap out one issue for another :sweat_smile: it was indeed my assets being too large causing the infinite loop! i spent a lot of time changing images into multiples of 4 so they could be compressed, and now things are a little more reasonable:

Build Report
Uncompressed usage by category (Percentages based on user generated assets only):
Textures               327.7 mb	 80.2% 
Meshes                 0.0 kb	 0.0% 
Animations             1.0 mb	 0.3% 
Sounds                 71.3 mb	 17.4% 
Shaders                43.2 kb	 0.0% 
Other Assets           8.5 mb	 2.1% 
Levels                 0.0 kb	 0.0% 
Scripts                132.4 kb	 0.0% 
Included DLLs          0.0 kb	 0.0% 
File headers           114.2 kb	 0.0% 
Total User Assets      408.9 mb	 100.0% 
Complete build size    159.0 mb

however, i now have a different issue: the game hangs for about 30 seconds when transitioning to the game scene, then my browser goes black for a second, and then i get a grey screen with this warning:

WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost

this happens in both build-and-run + on itch. not sure if this means i still havent reduced the assets far enough?

might depend on your memory usage, as an example, a lot of mobiles will reset if you exceed a memory threshold

update: definitely was a memory issue, switched to using sprite atlases to reduce the asset sizes even more, and the game runs fine now!

Build Report
Uncompressed usage by category (Percentages based on user generated assets only):
Textures               137.3 mb	 62.8% 
Meshes                 0.0 kb	 0.0% 
Animations             1.0 mb	 0.5% 
Sounds                 71.3 mb	 32.6% 
Shaders                43.2 kb	 0.0% 
Other Assets           8.6 mb	 3.9% 
Levels                 0.0 kb	 0.0% 
Scripts                132.4 kb	 0.1% 
Included DLLs          0.0 kb	 0.0% 
File headers           95.9 kb	 0.0% 
Total User Assets      218.6 mb	 100.0% 
Complete build size    152.8 mb
1 Like

I’d say so. You managed to reduce texture size by a factor of 100! :hugs:

1 Like