Handle cases where event handlers come in late in VR startup #1075
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The code currently has two hacks dealing with WebVR startup in A-Frame when a user refreshes the page after a VR session on desktop:
It's always been the case that A-Frame/WebVR will retain VR mode across refreshes, we have a hack that will exit VR mode on startup if this case is hit
There was a regression in 0.9.0 that causes A-Frame to miss this condition in certain conditions, resulting in a situation where the display is presenting but A-Frame did not run its relevant "enter VR" routines (to tag the scene metadata, set up cameras, etc.)
The previous hacks handled these cases by subscribing to
enter-vrandvrdisplaypresentchangeto get out ahead of these conditions, but in practice it looks like in certain cases these event subscriptions are happening too late, the events have already fired (for both conditions.) This PR updates them to both be handled when these events fire but also pre-emptively run the necessary logic at event subscription time in case the event has already fired.