ComfyUI Node

RM Mask Gate

Stop empty masks from crashing your workflow

By Moser9815·Created 7 months ago·Updated 7 days ago· 0
RM Mask Gate
  • mask
  • mask

Some nodes in ComfyUI treat an empty mask as a hard crash; others, worse, silently do nothing. In a conditional workflow - a detection that found no face, an inpaint branch that produced no region - the "mask" downstream can arrive empty or all zeros, and whether that kills the run is basically a coin flip per node. RMMaskGate is the checkpoint that makes it deterministic: it validates the mask and passes it through only if it's actually usable. Otherwise it outputs None, so downstream nodes can handle "no mask" on their own terms instead of exploding.

How it works

The validation is strict and visible in the console. A mask fails the gate if it's None, has zero elements, has any zero dimension, or sums to zero (an all-black mask is a "no mask" in every practical sense). Each rejection prints exactly which condition it tripped, and the output becomes None. A genuinely usable mask - non-empty, non-zero, with actual white in it - passes through unchanged. That's the entire mechanism, and that's fine: this is a guardrail, not a feature factory.

It slots in right before anything you know crashes on empty masks - a Set Latent Noise Mask, a regional conditioning node, a compositing step. Combined with the pack's RMMaskCombine (which returns None when no input mask is valid), you get a whole conditional-mask pipeline that degrades gracefully instead of erroring.

Inputs and outputs that matter

  • mask (MASK, optional) - the mask under test.
  • mask (output) - the same mask if valid, None otherwise.

How to install it

Part of the RMAutomation pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Moser9815/ComfyUI-RMAutomation

Restart ComfyUI; it's under RMAutomation/Mask. No dependencies.

Common issues

The one thing to remember is that None is a choice, not an error - whatever you connect downstream has to tolerate a None mask, or you've just moved the crash. If the node rejects a mask you expected to pass, check the console line: all-zero (sum = 0) and zero-dimension are different failure modes, and all-zero usually means the mask came from a failed upstream operation rather than a genuine "this region is protected." A legitimately all-black mask for "protect everything" will get gated out, which is correct behavior - use RMMaskGateGuide's sibling philosophy: think of this node as "is there anything to do?" and let it answer honestly.

CategoryRMAutomation/Mask

Inputs (1)

NameTypeDefaultDescription
maskoptMASK

Outputs (1)

NameTypeDescription
maskMASK