Closed michaelwasserman closed 4 years ago
I think that as we've built out the Web Platform we've come to consider that "live" are an anti-pattern. Modern APIs should return (frozen) snapshots of information, whenever this doesn't harm performance too much. I think this API should use snapshots. In other words, getScreens
/ getDisplays
should return objects whose properties never change.
Thanks for that insight! In that case, I wonder if it makes sense to modernize the Screen
object as obtained through window.screen
, to behave in the same manner, or if that object should behave differently from our proposed Screen
object as obtained through getScreens()
. My naive inclination would be to modernize the existing window.screen
object too. Thoughts?
So, for example, the Screen
object returned by window.screen
might not always be the same object, but once captured e.g. s = window.screen
the properties on s
would never change? Seems plausible...
It seems like this would be backwards compatible with code written to reference window.screen
(or just screen
since window is the global...) directly, any code that held a reference (e.g. var s = window.screen
) would see the snapshot and not any updates. I could imagine code optimizers doing this (i.e. to save bytes); we could maybe do an HTTPArchive search, but it may just be a matter of taking the chance.
The updated and consolidated proposal suggests static snapshots of screen information. webscreens/window-placement#18 discusses this topic further and suggests "file a CSSOM View issues to ask them to deprecate the main screen object, and then cut its properties down to just what is necessary for web compat", so I'll close this issue and proceed as advised there.
A question about the lifetime of Screen objects was raised recently:
We should consider this further, but my initial inclination would be to allow the Screen to exist beyond the lifetime of any LocalFrame. One requirement of this interface is providing screen information to open a window when a worker doesn't have any windows open (perhaps triggered by a notification). That scenario might be more difficult if the Screen lifetime is linked to that of a LocalFrame. Perhaps allowing Screens to exist while a notification is being handled could be sufficient?