With the [[ https://wicg.github.io/event-timing/ | Event Timing API ]] origin trial I'm currently running, I've noticed regular occurrences of the click on the X to close Media Viewer causing a long event handler (>50ms). This will result in frame drops and momentary browser lockup.
It seems like Media Viewer is doing quite a bit of work when it gets closed. It would be desirable, in order for the page to remain more responsive, to move as much of this work as possible outside of the event handler. I.e. done asynchronously after the fact, using [[ https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback | requestIdleCallback ]], for example.
It would also be good to audit whether all of this work is strictly necessary, and if we couldn't leave some things "attached" until the next time Media Viewer is invoked.