Dynamically created Tilemap tiles render in editor and Android build but not in WebGL build

My last two projects have been using Tilemaps with small sprites to dynamically create tiles. The previous one I didn’t finish (7DRL), so I didn’t get around to addressing deployment, but now I’m getting there and am trying to solve this issue.

I build a test project to get a minimal reproducible script, and this does it:

using UnityEngine;
using UnityEngine.Tilemaps;

public class TileTest : MonoBehaviour {
	public Tilemap tilemap;
	public Sprite floorSprite;

	void Start () {
		Tile tile = new Tile();

		tile.sprite = floorSprite;
		tilemap.SetTile(new Vector3Int(1, 1, 0), tile);

		tile = ScriptableObject.CreateInstance<Tile>();
		tile.sprite = floorSprite;
		tilemap.SetTile(new Vector3Int(-1, -1, 0), tile);

The sprite is just a small PNG, and the tilemap is a Tilemap object inside of a Grid (normal). This script is attached to the grid. That’s exactly all there is to this project.

In the editor and in Android builds, both of the instantiations work. The first generates a warning, which is expected; I just wanted to try directly to see if the behavior varied, which it doesn’t.

I can’t find anything in Build Settings or PlayerSettings that seems like it should impact this. The sprite is referenced on the script on the grid, and just to make sure, I put the Sprites folder in a Resources folder; no change. Firefox and Chrome/Chromium (I’ve tested this in Windows 10 and Debian 9) both just display a blank canvas, which is the right color for the build (and in the more complex projects it also displays my non-tile sprites and animations), but no tile sprites render.

In the actual project, I’m dynamically instantiating prefabs with animations that work fine across all platforms. Why would it be failing in WebGL?

Turns out this is a known bug in Unity that’s been waiting for a fix for a while now… it’s supposedly been fixed “in a future release,” though the current beta still chokes on it.