What widgets are used on a page? [closed]

This is unsolvable in general case, since widgets can be either generated by sidebar calls in arbitrary locations of templates or (rarely) even rendered individually without sidebar.

So for general case at best you can hook into the processes and run some logic at the end of page load.

If you are working on specific bespoke site you can be more flexible. If you know in advance which sidebars are expected to run on page you could try to examine data structures early in the load process.

You don’t provide much context, but my educated guess would be that trying to make global page context conditional on widgets somewhat goes against the whole idea of widgets as contained pieces. If I saw this in the wild my first thought would be that widgets are being over–architectured into a role they are not meant to perform.