react-unity-webgl icon indicating copy to clipboard operation
react-unity-webgl copied to clipboard

wasm file downloads twice

Open MarkZamoyta opened this issue 2 years ago • 5 comments

Please avoid duplicates

Language and Compiler

TypeScript's built-in Compiler

What environment are you using?

Local Development Server

When does your problem occur?

When the Unity Component mounts

What does your problem relate to?

The problem seems Unity related

React-Unity-WebGL Version

9.4.3

React Version

17.0.2

Unity Version

2021.3.16f1

What happened?

My game downloads but gets stuck for 25 seconds at 90%. I looked at what was going on during that time, and the browser is downloading the wasm file twice. On a chromebook with limited resources, it doesn't get cached (ever), so this doubles the download time. On a PC, everything is fine because the wasm file is cached after the first download, and the 2nd download is near instant. Is there a way to prevent it being downloaded twice? It happens somewhere in useUnityContext() before it sets isLoaded to true.

Reproducible test case

No response

Would you be interested in contributing a fix?

  • [ ] yes, I would like to contribute a fix

MarkZamoyta avatar Nov 15 '23 19:11 MarkZamoyta

would it be able for you to share some code? it might be caused by unintentional rerenders

jeffreylanters avatar Nov 20 '23 09:11 jeffreylanters

i also got the same issue on my PC chrome and mobile chrome. the *.wasm file will download twice.

lzqlawrence avatar Dec 26 '23 16:12 lzqlawrence

I looked into rerenders, I'm new to react so I figured that could be the case, but rerendering wasn't the problem. Unfortunately many schools have extremely slow wifi, so I was forced to drop Unity for just plain JS, which is about 1/20th the size for my game. Even downloading a Unity game once is way too slow, and Chrome won't cache it on limited devices. What's the best way to get you my code in case it can help someone else? Thanks, Mark

On Mon, Nov 20, 2023 at 4:13 AM Jeffrey Lanters @.***> wrote:

would it be able for you to share some code? it might be caused by unintentional rerenders

— Reply to this email directly, view it on GitHub https://github.com/jeffreylanters/react-unity-webgl/issues/531#issuecomment-1818512790, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADAEM2IL7KSO4CKDANEBJWDYFMNLFAVCNFSM6AAAAAA7NAHHXOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJYGUYTENZZGA . You are receiving this because you authored the thread.Message ID: @.***>

MarkZamoyta avatar Dec 30 '23 01:12 MarkZamoyta

i also got the same issue on my PC chrome and mobile chrome. the *.wasm file will download twice.

when i build a release build, it's fine. so the *.wasm file only download twice in development build

lzqlawrence avatar Mar 01 '24 11:03 lzqlawrence