Masking issues on legacy

I’m trying to apply a dynamically drawn mask to a sprite. The mask is made up of a single sprite with graphics rects drawn onto it. The target is a Sprite with multiple bitmap children.

When the mask is visible (not applied as a mask) the mask shape appears as it’s supposed to. This presumably shows there are no issues with the drawing code. Once the mask is applied, it seems to mostly work but there are artefacts as though part of it doesn’t get drawn or it hasn’t cleared some parts properly.

Does anyone know what might cause this? Is it possible to make a mask visible and be a mask so I can try to debug? I’m currently using openfl-legacy due to other issues.