Error when attempting to Set a Tile in Unity

I get this error:

In order to call GetTransformInfoExpectUpToDate, RendererUpdateManager.UpdateAll must be called first. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

when trying to do this:

public void Test()
    Tile floorTile = ScriptableObject.CreateInstance<Tile>();
    Tilemap tilemap = GameObject.Find("Tilemap").GetComponent<Tilemap>();

    floorTile.sprite = Resources.Load<Sprite>("Scenes/Maze/Sprites/Terrain/white256") as Sprite;
    tilemap.SetTile(new Vector3Int(0, 0, 0), floorTile);

The tilemap is getting found (!= null); I can see the sprite in the viewport

using unity 2023.2.2f1

So I changed the “Detect Chunk Culling Bounds” option in the tilemap to “Manual” and now no errors are getting displayed. I still have no idea why it does this though.