I found what I think was the problem for me: From the desktop, I was starting Firefox with the “--no-remote” option. If I remove that option, then it works. I did not use that option when starting in a terminal, but if I do, then the same problem appears.
You cannot start FF from the Desktop and then start new windows from a shell.
Unless that shell was directly started from the desktop.
So it must have something to do with the environment or process tree.