On which moment is the xml tree generated for native iOS app


I’m using appium-python-client and ‘Appium XCUITest driver’

To have a better understanding how this is working, I would like to know on which moment the xml-file (page_source) is generated.
Is this always before a request is send from the client script?
Or is this when the content of the screen change?

Is there a way to regenerate this xml-file? (in case the element is not found, but displayed on the screen)

Have you tried to use explicit waits to avoid possible race conditions?

The page source is requested from xctest each time the /source webdriver API is called.