openURLContexts: not called every other time?

I've implemented a UIDocumentBrowserViewController-based macCatalyst app. I can open files from the file browser, but I'm having trouble opening files from Finder.


When I selected "open in" from Finder, the system alternately calls

scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)

with 0 elements in the connectionOptions.urlContexts and does not call

scene(_ scene: UIScene, openURLContexts URLContexts


The next time I try to open a file from finder, the system does call

scene(_ scene: UIScene, openURLContexts URLContexts

on the scene connected in the previous call (with the newly selected document url) and my app correctly opens the document in the urlcontexts.


The next time I try open a file from finder, the sequence repeats, with the system calling

scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)

again, also with no files in the connectionOptions.urlContexts, and no call to openURLContexts.


The sequence actually starts with the call to openURLContexts, as there is already a connected scene with no presented document.


What do I need to do to make the system call willConnectTo with the file url in the connectionOptions.urlcontexts the first time?