I ran into a similar problem once, but I cannot associate it directly with your code.
In short, the problem is that while I create my layer / scene in the init method, nodeToWorldTransformation (at least, possibly others) is not installed. So, if you are trying to calculate the world coordinates (or perhaps the size in world coordinates) of something, this will not work.
Now, in the case, I used this transformation to calculate the scale factor during init, and that was wrong. If I postponed the calculation before the conversion was established, everything was in order. The transformation will be ready only after the layer you create is added to its parent element, but I'm not quite sure when it does it. Finally, in my case, I just encoded the transform, knowing all the dimensions during init.
It seems that your case may be similar to this, but, as I said, I cannot associate this with your code.
source share