Quick answer: Replace nested Mask with RectMask2D. Or limit Mask nesting depth to under 8 levels.

Inventory window with nested scroll views. Some children fail to clip. Stencil ref count exceeded 255.

The Fix

Use RectMask2D for rectangular clipping:
  ScrollView (RectMask2D)
    Item (Image)
    Item (Image)

Mask only when shape is non-rect (e.g. circular avatar):
  AvatarPanel (Mask, with circle Image)
    AvatarImage

RectMask2D uses scissor; no stencil bits consumed. Mask reserved for shaped clipping.

Verifying

All children clipped correctly. Profiler: fewer draw calls when RectMask2D replaces deep Masks.

“RectMask2D for rect. Stencil for shapes.”

Related Issues

For Canvas Scaler, see scaler. For TMP color, see TMP color.

RectMask2D. No stencil cost.