You are trying to get the position on viewport before you add the widget to it.
And you should add some delay between them: