In \tikz@subpicture@handle@ then the current figure name is appended to the name prefix key using the invocation:
\tikzset{name prefix/.prefix/.expanded=\tikz@fig@name}
The problem with this is that \tikz@fig@name will already have the current name prefix applied to it, so the current name prefix now appears twice.
Specifically, if name prefix is currently wibble and we name a pic wobble, then \tikz@fig@name will be wibblewobble and so the prefix to name prefix will be wibblewobble but name prefix will retain its value of wibble meaning that the effective name prefix is wibblewobblewibble.
See this question on TeX-SX for a reasonable minimal example.
See https://github.com/pgf-tikz/pgf/issues/311