Unity loop Application.EnterPlayMode

When I hit Play Unity makes me wait infinite time before start the scene. The message in Hold On window is “Application.EnterPlayMode
Waiting for Unity’s code to finish executing”. There is only one scene in URP with global volume, directional light and a plane with this script:

using UnityEngine;

public class PerlinNoise : MonoBehaviour
{
    [Header("Resolution")]
    [Space]
    public int width = 256;
    public int heigth = 256;
    [Space]
    [Header("Adjustments")]
    [Space]
    public float scale = 20;
    public float xOffset = 10;
    public float yOffset = 10;

    void Update()
    {
        Renderer renderer = GetComponent<Renderer>();
        renderer.material.mainTexture = GenerateTexture();
    }

    Texture2D GenerateTexture()
    {
        Texture2D texture = new Texture2D(width, heigth);

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; x < heigth; y++)
            {
                Color color = GenerateColor(x, y);
                texture.SetPixel(width, heigth, color);
            }
        }

        texture.Apply();
        return texture;
    }

    Color GenerateColor(int x, int y)
    {
        float xCoord = (float)x / width * scale + xOffset;
        float yCoord = (float)y / width * scale + yOffset;
        float perlinNoise = Mathf.PerlinNoise(xCoord, yCoord);
        return new Color(perlinNoise, perlinNoise, perlinNoise);
    }
}

I tried to kill unity editor task in task manager and restart unity but the same issue repeats.
Please help me

Why don’t you try to move the code on the Update method to the Awake or Start method?

Right now it’s just recreating the same texture for every update call and that might be the origin of the problem.