Await delay.task blocks the browser

Ho Everyone,
First of all, sorry in advance as I am completely new to programming/unity/this forum… I am trying to learn all by myself from scratch for fun, going through all the materials and q&a on the web, but this time I might be stuck as I was not able to find any helpful answer (but sorry if it was somewhere…).

So I developed a very basic “game” just to learn/practice, and I wanted to publish it in webGL format so it can be played from a browser (note that during development my “build setting” was set on Windows platform and I switched to WebGL before building), the problem is that on both unity play and itch.io, it looks like as soon as I reach a “await Task.Delay”, the browser blocks…

I checked the browser console that says when the game opens “WebGL warning: clientWaitSync: ClientWaitSync must return TIMEOUT_EXPIRED until control has returned to the user agent’s main loop. (only warns once)”. That must be it, should be an easy fix but I was unable to find out how to resolve this in my code/unity…

if you have any clue that would be much appreciated.

Anyways, many thanks to the whole community, I wouldn’t have come that far without all the answers you provide on various forums.

Here is a link to my game on unity play: https://play.unity.com/mg/other/my-game-that-does-not-work

And the code where the issue seems to be:

    public async void SetPlayerName()

        {
        if(firstP == true)
            {
                PS = PlayerStats.GetComponent<PlayerStats>();
                PS.Player1name = input;
                PS.activePlayer = PS.Player1name;
                PS.PlayerStatsUpdate();
                Player1nameEntered.text = PS.Player1name;
                iTween.ScaleTo(Player1Container, iTween.Hash("x", 4.0f, "y", 4.0f, "time", 1));
                GetComponent<AudioSource>().PlayOneShot(NameAppear);
                await Task.Delay(2000);
                FightImage.SetActive(true);
                iTween.ScaleTo(FightImage, iTween.Hash("x", 2.0f, "y", 2.0f, "time", 1));
                GetComponent<AudioSource>().PlayOneShot(FightAudio);
                inputfieldname.Select();
                inputfieldname.text = "";
                txt.text = "Enter Name of Second Player";
                firstP = false;
                Debug.Log(firstP);
               
            }
        else if(firstP == false)
            {
                PS = PlayerStats.GetComponent<PlayerStats>();
                PS.Player2name = input;
                PS.PlayerStatsUpdate();
                Player2nameEntered.text = PS.Player2name;
                iTween.ScaleTo(Player2Container, iTween.Hash("x", 4.0f, "y", 4.0f, "time", 1));
                GetComponent<AudioSource>().PlayOneShot(NameAppear);
                await Task.Delay(5000);
                RolltheDiceBox.SetActive(true);
                iTween.MoveTo(MessageBox, EndPanel.transform.position, 3.0f);
                await Task.Delay(3500);
                MessageBox.SetActive(false);
               
               
            }
        }

I should have added that in development, the game works perfect

WebGL has no multithreading support. Task.Delay() won’t work.
Check these threads for more info:

Async/await and webgl builds page-2#post-6855614

Would that function DelayAsync work for you as a replacement for Task.Delay?

Use UniTask