I discovered that when changing the bounding box, it is needed to hide the shadow, wait 1 frame and show the shadow again for the shadow size to be updated. But I don't know if it is the correct way to use it.
Anything that involves WAIT to work properly(within the same assumed time...while it isnt because of the wait) sounds bad.
programm should be able to work without ANY wait o.O